Answer the question
In order to leave comments, you need to log in
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());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question