netty / netty/netty

HttpPostRequestDecoder exception

Open
#10,324 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
35.1k
Forks
16.3k
Avg merge
1d 5h
Merged PRs (30d)
143

Description

Expected behavior
Actual behavior

HttpPostRequestDecoder exception

Steps to reproduce
  1. Add few lines to the Netty io.netty.example.http.helloworld.HttpHelloWorldServerHandler:
    ....
    @Override
    public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) {
    if (msg instanceof HttpRequest) {
    HttpRequest req = (HttpRequest) msg;
    // Lines to add:
    if (req.method() == HttpMethod.POST) {
    HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE);
    new HttpPostRequestDecoder(factory, req);
    }
    // end

  2. Launch io.netty.example.http.helloworld.HttpHelloWorldServer

  3. Post the following request to the 127.0.0.1:8080 address
    Exception rised: io.netty.handler.codec.http.multipart.HttpPostRequestDecoder$ErrorDataDecoderException: Bad string ...

Request to post (here html tags are substituted by < and >):
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ><TransactionDetails>0004486 (20%) 8333-33</TransactionDetails></s:Body>

Actual request is attached

It is interestiing that exception is not rised
A. without percent sign in the request
B. or if new line "\n" is inserted before <TransactionDetails> tag

Minimal yet complete reproducer code (or URL to code)
Netty version

4.1.50

JVM version (e.g. java -version)

1.8.0_131

OS version (e.g. uname -a)

Win-10, CentOS 7.3.1611

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at io.netty.example.http.helloworld.HttpHelloWorldServerHandler and the HttpPostRequestDecoder construction described in the reproducer; run HttpHelloWorldServer with the supplied POST body on Netty 4.1.50. Trace why the percent sign causes ErrorDataDecoderException, and consider the issue resolved when the request is handled without that exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.