I wonder how we could make the API documentation more clear about this:
https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/ext/MessageBodyWriter.html#writeTo(T,%20java.lang.Class,%20java.lang.reflect.Type,%20java.lang.annotation.Annotation[],%20javax.ws.rs.core.MediaType,%20javax.ws.rs.core.MultivaluedMap,%20java.io.OutputStream) <
https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/ext/MessageBodyWriter.html#writeTo(T,%20java.lang.Class,%20java.lang.reflect.Type,%20java.lang.annotation.Annotation%5B%5D,%20javax.ws.rs.core.MediaType,%20javax.ws.rs.core.MultivaluedMap,%20java.io.OutputStream)>
<quote>
The message header map is mutable but any changes must be made before writing to the output stream since the headers will be flushed prior to writing the message body.
</quote>
IOW, yes, you can update the header map and expect the updated map to be written as soon as you invoke your first write operation on the entity stream.
Marek
> On 25 Feb 2015, at 09:00, Maarten Boekhold <boekhold_at_gmx.com> wrote:
>
> Hi,
>
> Looking at this again, and I'm actually a little confused as to how I can manipulate the HTTP headers from here. Should I just update teh MultivaluedMap<String, String> httpHeaders? If so, I assume that the runtime will actually write out the contents of httpHeaders upon the first call to entityStream.writeTo()?
>
> Maarten
>
> On 2015-02-24 20:29, Marek Potociar wrote:
>> Yes, but ONLY BEFORE you write first few bytes into the output stream.
>>
>> Marek
>>
>>> On 22 Feb 2015, at 13:20, Maarten Boekhold <boekhold_at_gmx.com> wrote:
>>>
>>> Hi,
>>>
>>> As per the subject: is this allowed/possible?
>>>
>>> Maarten
>