[jax-rs-spec users] [jsr339-experts] Re: Altering response headers in a buffering writer interceptor

From: Markus KARG <>
Date: Tue, 6 Nov 2012 20:12:37 +0100


> -----Original Message-----
> From: Jan Algermissen []
> Sent: Dienstag, 6. November 2012 17:52
> To:
> Subject: [jsr339-experts] Altering response headers in a buffering
> writer interceptor
> One of the canonical examples for interceptors is to buffer the output
> stream, derive some form of value from it (e.g. in the digital
> signature case) and add that value to the response headers *before*
> streaming out the buffer.
> In order to make this work, there needs to be a guarantee that the
> runtime definitely waits for the first byte to arrive in the output
> stream before sending out the headers.
> While that is, to my knowledge, common practice in HTTP server software
> it is AFAIK an implementation choice. I cannot see JAX-RS runtime
> implementations to be required to behave like this. It would be
> perfectly valid to implement a runtime that sends the headers
> immediately, e.g. when <mbw>.getSize() returns -1.
> Wouldn't it be a good idea to add to the spec a constraint to require
> the runtime to not send any response headers until the first byte hits
> the output stream?
> Jan