N
N
Nikita Sklyuev2012-05-25 10:03:07
Java
Nikita Sklyuev, 2012-05-25 10:03:07

Expect: 100-Continue How to get rid of it?

Hello dear habrchane.
I am making my first android app.
I encountered one unpleasant problem, when sending a POST request to the header, an incomprehensible header " Expect: 100-Continue " is added, due to which the server gives me an error.
The server is third-party, so I can’t make any changes on it.
Here is the code for sending the request:

HttpClient httpClient = new DefaultHttpClient();
      HttpPost httpPost = new HttpPost("http://www.mysite.ru/index.php");
      
      
      
      String Ent="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
          "<client><call>*****</call></client>";
      
      StringEntity requestEntity = new StringEntity(Ent); 

      requestEntity.setContentType("application/x-www-form-urlencoded");			
      httpPost.setEntity(requestEntity);
      httpPost.setHeader("Connection", "Keep-Alive");
      httpPost.setHeader("Accept-Encoding", "gzip");
      httpPost.setHeader("Accept-Language", "ru-RU,en,*");
      httpPost.setHeader("User-Agent", "Mozilla/5.0");
      httpPost.setHeader("Host", "*************");

      HttpResponse response = httpClient.execute(httpPost);
      
      InputStream data = response.getEntity().getContent();

      ByteArrayOutputStream content = new ByteArrayOutputStream();

      int readBytes = 0;
      byte[] sBuffer = new byte[512];
      while ((readBytes = data.read(sBuffer)) != -1) {
        content.write(sBuffer, 0, readBytes);
      }

      String dataAsString = new String(content.toByteArray());

Please help me get rid of this disease!
PS I work in the emulator, there is no proxy!
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mik_os, 2012-05-25
@trilodi

httpPost.setHeader("Expect", "");
or
httpPost.removeHeaders("Expect");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question