Remove Expect header in Android’s org.apache.http

The removeHeader() call won’t work for you. You have to remove a request interceptor.


DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.removeRequestInterceptorByClass(
org.apache.http.protocol.RequestExpectContinue.class);

This took me a while to track down, unfortunately, so I’m blogging it here so others can hopefully save some time.

2 Comments

  1. Johann says:

    Thanks, I just had this problem, too.

    For the people using Groovy HTTP Builder:

    HTTPBuilder builder = createHTTPBuilder()
    builder.client.removeRequestInterceptorByClass(RequestExpectContinue)

  2. Mike says:

    Good to know! Hopefully now people won’t have to spend hours like we did.

Leave a Reply