Closed kwrooijen closed 1 year ago
When the server does that, it's completely impossible to tell whether the server just gave the wrong value for the header, or if it crashed and failed to send the full response.
I can add an option to treat an incomplete body as "expected" but that feels very unreliable.
I added an option on RawHttpOptions
to allow for this, see example in the test:
https://github.com/renatoathaydes/rawhttp/commit/97d94ef8451e313478f9024acf240f823a8a1044#diff-406613a18b54c44acab140482b0332c4d4b0cf646f2465c6d4c818dd0bbd5f33R212
Currently when a response returns less data than specified in
Content-Length
, RawHTTP will crashhttps://github.com/renatoathaydes/rawhttp/blob/d51e4cedc22c1478ea186538b70e22ef2fdb1e53/rawhttp-core/src/main/java/rawhttp/core/body/BodyConsumer.java#L158-L159
In my case I'm not the owner of the server, I can't fix this flaw. So even though the server is technically incorrect, I still want to be able to handle it.
A possible solution would be to add a flag to indicate that I want to either consume
Content-Length
amount or less. If it is less thanContent-Length
then I want to pull as much as possible without crashing.