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

[jsr339-experts] Altering response headers in a buffering writer interceptor

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Tue, 6 Nov 2012 17:51:44 +0100

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