jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Trailers with JAX-RS

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Fri, 28 Sep 2012 21:25:09 +0200

On Sep 28, 2012, at 8:04 PM, Marek Potociar wrote:

>
> On Sep 26, 2012, at 3:10 PM, Jan Algermissen <jan.algermissen_at_nordsc.com> wrote:
>
>> Hi,
>>
>> verifying my understanding...
>>
>> Given the abstraction that JAX-RS creates on top of HTTP connectors, it seems impossible to send or receive HTTP trailers with JAX-RS. Even if the underlying connector does support them.
>>
>> Or am I missing a clever trick?
>
> Could an interceptor be used for that?

The problem, as I see it, is that the connector (e.g. Grizzly) is in charge of the output stream. If no Content-Length is set by JAX-RS the connector will chunk-encode the response stream and from a JAX-RS perspective there is no hook to add Trailers after the last chunk. Whatever you send will ge chunked, too.

(I am also not entirely sure that Grizzly, for example, provides a hook to add trailers.)

Maybe sth for JXA-RS 4.0 :-)

Jan

PS Yes, it is unfortunately an edge case and many clients do not support reading the trailers anyhow. Apache Client does, BTW.


>
>>
>>
>> Anyone knows the history regarding this detail?
>
> Hmm... I don't know but perhaps the reason is that it's not a frequently used feature, or is it?
>
> Marek
>>
>>
>> Jan
>>
>>
>