Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Problem reading POST body with embedded Jetty 12.0.x


>> On Mon, Sep 11, 2023 at 2:16 PM Silvio Bierman via jetty-users
>> <jetty-users@xxxxxxxxxxx> wrote:
>> >
>> > It appears that all handling of POST requests with ZIP-content as
>> > payload in our application is broken with Jetty 12 (I tried both 12.0.0
>> > and 12.0.1). We use an embedded Jetty-12 with ee10 and http/2.
>> >
>> > Using Jetty 11 the code works as expected.
>> >
>> > We post a ZIP-file from the command line using Curl to the application.
>> > The handling code wraps request.getInputStream in a BufferedInputStream
>> > wrapped in a ZipInputStream and starts reading ZipEntry objects with
>> > getNextEntry until this returns null. With Jetty 12 this code only
>> > manages to read the first part of the POST-body and then blocks
>> > indefinitely. This is not a multi-part request, the ZIP-content is
>> > simply used as the request payload.

I have written a test case similar to what you describe, as it passes
cleanly, although careful coding is necessary.

The test case is here:

The careful coding is necessary because reading until getNextEntry()
returns null is not enough.
You must also read from the request InputStream until you read -1
(this is line 65 in the test).
This guarantees that Jetty knows that all the content has been
consumed, and it does not fail the request because not all the content
has been read.
Without the read until -1, the tests randomly fail, more often for
HTTP/2, but definitely also for HTTP/1.1, both in Jetty 12 and in
Jetty 10/11.

At this point, you have to show us your code.
Please file an issue and post your code there, as GitHub is better for this.

>From the Jetty point of view, with the test I linked, seems that
everything is correct, provided the careful coding is present.

Simone Bordet
Developer advice, training, services and support
from the Jetty & CometD experts.

Back to the top