How do I get Jersey Test/Client to not fill in a default Accept header?
<p>I'm trying to handle a request with no <code>Accept</code> header in a particular way, but Jersey seems hell-bent on filling one in, no matter what I do, so it always looks like the request has an <code>Accept</code> header, even if it doesn't.</p>

<pre><code>import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Test;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;

import static org.junit.Assert.assertEquals;

public class JerseyTestTest extends JerseyTest {

    @Path("hello")
    public static class HelloResource {
        @GET
        public String getHello(@Context HttpHeaders httpHeaders) {
            String acceptHeader = httpHeaders.getHeaderString(HttpHeaders.ACCEPT);
            return acceptHeader != null ? acceptHeader : "No Accept Header";
        }
    }

    @Override
    protected Application configure() {
        return new ResourceConfig(HelloResource.class);
    }

    @Test
    public void test() {
        final String hello = target("hello").request()
                .header(HttpHeaders.ACCEPT, null) // null means remove header
                .get(String.class);
        assertEquals("No Accept Header", hello);
    }
}
</code></pre>

<p>This test results in:</p>

<pre><code>org.junit.ComparisonFailure: 
Expected :No Accept Header
Actual   :text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
</code></pre>

<p>Somehow there is a default <code>Accept</code> header of <code>text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2</code> that gets set somewhere. It's not documented, and I would love to figure out how to disable it. I've looked through the Jersey source, but can't seem to locate where this is happening or why.</p>

<p>Update: when I use curl to hit an endpoint without an Accept header, there is no generated Accept header, so the problem lies in Jersey Client or the Jersey Test environment, somehow.</p>

<p>Update 2: This bug exhibits when using the default Grizzly2 test container or the JDK test container, but NOT with the In Memory test container.</p>