My headers are not correctly passed from client to server when using JerseyTest
.
Both server and client have MessageBodyWriter
and MessageBodyReader
configured respectively with JerseyTest::configure
and JerseyTest::configureClient
.
My MessageBodyWriter
add some custom headers to query :
@Override
public void writeTo(MyPojo myPojo, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
httpHeaders.put("X-Custom-Header", singletonList(myPojo.header()));
}
but when MessageBodyReader
is hit by server, it contains only standard headers.
Any clues on what I'm missing ?
Ok seems a bug with
InMemoryConnector
:All standard headers are set with :
containerRequest.getHeaders().putAll(clientRequest.getStringHeaders());
But if you provide custom headers, they are read but never added to
containerRequest
:final MultivaluedMap<String, Object> clientHeaders = clientRequest.getHeaders();
also https://java.net/jira/browse/JERSEY-2341 suggest it won't be fixed soon.