vert.x
vert.x copied to clipboard
Validate content length early during HttpServerResponse#sendFile
In HttpServerResponse#sendFile
, when the offset is greater than the file length, the calculated content length is negative. Currently, the value is not validated until after the head (response status and other headers) is written. An application might have downstream processing that would act on the IllegalArgumentException
thrown when validating the content length. However, it is too late for the downstream processor to write a different response status (for example a 400 BAD REQUEST), to signal the client that the request is not valid. The problem is exacerbated when the downstream processor tries to write a status code, because the IllegalStateException
exception will be thrown because the Response head is already sent
. This leaves the connection hanging on the server side, while the client is expecting content.
Motivation:
Explain here the context, and why you're making that change, what is the problem you're trying to solve.
Conformance:
You should have signed the Eclipse Contributor Agreement as explained in https://github.com/eclipse/vert.x/blob/master/CONTRIBUTING.md Please also make sure you adhere to the code style guidelines: https://github.com/vert-x3/wiki/wiki/Vert.x-code-style-guidelines
I will provide a patch for master
shortly.
I found a couple additional issues that I will address shortly. They've been fixed for the PR against master