[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Answering requests without reading body
|
Hi,
On Sat, Dec 14, 2024 at 2:07 PM Matthias Pfau via jetty-users
<jetty-users@xxxxxxxxxxx> wrote:
>
> Hi there,
> in some case we don't want to read the full body of a request but still send a response code and headers back to the client. Think of a resource that is used for uploading 10MB large files that wants to throttle clients by sending 429 status code and Retry-After headers to the client.
>
> We made the following observations when using the Handler API with http2:
>
> 1. If we set the status code and header manually and succeed the callback jetty throws a static exception due to unconsumed request content. This looks like a connection issue to the client because the server closes the stream without sending the info we set on the response.
>
The server should send a RST_STREAM to the client (which closes the
stream), which will not impact the connection (which will remain open
and functional for other requests).
The client should receive a HEADERS frame with the response, and a
RST_STREAM immediately after.
What client are you using?
If you're using Jetty's HttpClient, it should be guaranteed that you
see the response headers.
A Response.CompleteListener may receive a failed Result because the
request has been failed (could not be uploaded), but the Response
object should have all the relevant headers.
If that's not the case, and you have a reproducer, please open an
issue about this.
> 2. When we fail the callback with an HttpException with the proper code, we receive that code on the client, but any headers we set before failing the callback seem to be ignored.
>
> org.eclipse.jetty.http.HttpException seems to be handled in a special way. Is there any documentation on this and is there a way to also set headers when a callback is failed?
It is not treated in a special way, it is just internally used to
specify an error code that is relayed in the response.
What I wrote above should apply to HttpException as well, so again if
you have a reproducer (for both cases), please open an issue.
--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.