|Re: [jetty-users] Problem reading POST body with embedded Jetty 12.0.x
Hi Simone,I stripped my code down to what I consider the bare minimum. The issue still persists. I posted an issue containing my test code.
https://github.com/eclipse/jetty.project/issues/10513 Cheers, Silvio On 12-09-2023 20:25, Simone Bordet wrote:
Silvio,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: https://github.com/eclipse/jetty.project/pull/10502/files#diff-0016119d5f34ccf50bb7920bead0bf5e175027028bb45bcc212bb52ba0996f23 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.
Back to the top