Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad requests are not handled as such #309

Closed
nathankooij opened this issue Mar 21, 2018 · 0 comments
Closed

Bad requests are not handled as such #309

nathankooij opened this issue Mar 21, 2018 · 0 comments
Labels
type/bug A general bug
Milestone

Comments

@nathankooij
Copy link

nathankooij commented Mar 21, 2018

Whenever Netty fails to decode a HttpRequest due to a TooLongFrameException because for instance the HTTP line max size has been exceeded, this is not treated as a bad request by reactor-netty as such. Instead an empty default request is bubbled up (which then in my case fails as it is considered Unauthorized due to the stripped headers in my Spring Boot application).

Expected behavior

Decoder failures should result in bad requests, and not return empty default requests. Preferably the right status code is set (414 if the request URL is simply too long e.g.), but having it return as a bad request would already be a big improvement.

Actual behavior

If the request cannot be decoded, an empty default request with URL GET :/bad-request is returned.

Steps to reproduce

    NettyContext context = HttpServer
            .create(8081)
            .newHandler((req, res) ->
                    req.receiveContent()
                            .map(DecoderResultProvider::decoderResult)
                            .reduce((a, b) -> b)
                            .map(DecoderResult::cause)
                            .map(Throwable::toString)
                            .flatMap(cause -> res.sendString(Mono.just(cause)).then()))
            .block();

Issue a simple CURL request with a query param containing a (long) list of IDs:

curl -vvv http://localhost:8081/test?ids=234239,234239,234239,234239,234239,234239,234239,234239,24239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239,234239

results in:

> Host: localhost:8081
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< transfer-encoding: chunked
< connection: close
< 
* Closing connection 0
io.netty.handler.codec.TooLongFrameException: An HTTP line is larger than 4096 bytes.

Reactor Netty version

0.7.5.RELEASE

JVM version (e.g. java -version)

openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

OS version (e.g. uname -a)

Linux 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

@violetagg violetagg added the type/bug A general bug label Mar 21, 2018
@violetagg violetagg added this to the 0.7.6.RELEASE milestone Mar 21, 2018
violetagg added a commit that referenced this issue Mar 21, 2018
…n 4xx response

When the decoding failed with "TooLongFrameException", "413 Request
Entity Too Large" will be returned otherwise "400 Bad Request"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants