最近将所有数据移到新服务器上,在所有org.apache.http.NoHttpResponseException: The target server failed to respond
链接中得到此异常JSON
但它在浏览器中完美运行。在旧服务器中它运行良好。我无法解决此问题。任何人都知道请帮我解决这个问题。
编码
HttpClient client;
HttpResponse response;
HttpPost post;
InputStream in;
StringEntity se;
int resp_code;
client = new DefaultHttpClient();
post = new HttpPost(getString(R.string.base_url)+ "getCityList");
response = client.execute(post);
resp_code = response.getStatusLine().getStatusCode();
InputStream in = response.getEntity().getContent();
String a = json_res_class.convertStreamToString(in);
记录Cat错误
09-10 11:55:22.369: W/System.err(2214): org.apache.http.NoHttpResponseException: The target server failed to respond
09-10 11:55:22.369: W/System.err(2214): at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:85)
09-10 11:55:22.381: W/System.err(2214): at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174)
09-10 11:55:22.381: W/System.err(2214): at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180)
09-10 11:55:22.381: W/System.err(2214): at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
09-10 11:55:22.405: W/System.err(2214): at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
09-10 11:55:22.405: W/System.err(2214): at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
09-10 11:55:22.409: W/System.err(2214): at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
09-10 11:55:22.409: W/System.err(2214): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
09-10 11:55:22.413: W/System.err(2214): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
09-10 11:55:22.413: W/System.err(2214): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
09-10 11:55:22.421: W/System.err(2214): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
答案 0 :(得分:0)
使用它:
HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), false);