jrudolph commented on issue #460:
URL: 
https://github.com/apache/incubator-pekko-http/issues/460#issuecomment-1916675787

   I can somewhat reproduce your issue, assuming that you cancel the request 
stream after having read all bytes (which is somewhat expected based on the 
`TakeUpTo` -> `fold` -> `headOption` flow but cancellation is somehow not shown 
in your logs?). If that's really the case, then the behavior is somewhat 
expected but probably under-documented. You must not cancel a request entity 
stream if you want to send out a response (but slurp the rest in, in this case, 
the rest would actually be empty but you still need to request it instead of 
cancelling the stream).
   
   Here's the test, to be put into `HttpServerSpec`:
   
   ```scala
       "round-trip with HTTP/1.0 POST request with Default entity (entity 
received in bits) and Connection: close" in assertAllStagesStopped(new 
TestSetup {
         send(
           """POST / HTTP/1.0
             |Host: example.com
             |Connection: close
             |Content-Length: 12
             |
             |abcdef""")
   
         val entity =
         inside(expectRequest()) {
           case HttpRequest(POST, _, _, entity, _) =>
             entity.contentLengthOption shouldEqual Some(12)
             entity
         }
         requests.request(1) // emulate that the server with pull in more 
requests early
   
         val dataProbe = ByteStringSinkProbe()
         entity.dataBytes.runWith(dataProbe.sink)
         dataProbe.expectUtf8EncodedString("abcdef")
   
         send("ghijkl")
         dataProbe.expectUtf8EncodedString("ghijkl")
         dataProbe.cancel()
         // proper user behavior instead of cancel makes the test pass:
         // dataProbe.request(1)
         // dataProbe.expectComplete()
   
         // let the server some time to propagate messages / prepare the 
response
         Thread.sleep(2000)
   
         responses.sendNext(HttpResponse(protocol = HttpProtocols.`HTTP/1.0`))
         expectResponseWithWipedDate(
           """HTTP/1.0 200 OK
             |Server: pekko-http/test
             |Date: XXXX
             |Content-Length: 0
             |
             |""")
   
         shutdownBlueprint()
       })
   ```
   
   Somewhat similar previous instance: 
https://github.com/akka/akka-http/issues/3458
   
   (Above explanation about why localhost version work is still valid, request 
is received fully -> HttpEntity.Strict, data is now fully detached from the 
http connection, so whatever you do has no consequence on the actual 
connection).
   
   I can remember a previous issue of `head` being used with Play leading to 
issues but cannot find the reference any more (years ago).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to