我收到这样的回复:
HttpResponse response = httpclient.execute(httpget);
response.getStatusLine().toString());
在这种情况下,响应是:
HTTP/1.1 500 invalid user credentials
何我只收到消息,没有代码?
**invalid user credentials**
我收到这样的回复:
HttpResponse response = httpclient.execute(httpget);
response.getStatusLine().toString());
在这种情况下,响应是:
HTTP/1.1 500 invalid user credentials
何我只收到消息,没有代码?
**invalid user credentials**
尝试这个:
HttpResponse response = httpclient.execute(httpget);
StatusLine statusLine = response.getStatusLine();
String messageOnly = statusLine.getReasonPhrase();
int codeOnly = statusLine.getStatusCode();
很简单,这样做
String responseStr = EntityUtils.toString(response.getEntity());
这会奏效!
使用 StatusLine 接口的 getReasonPhrase() 方法。例如
HttpResponse response = httpclient.execute(httpget);
StatusLine statusLine = response.getStatusLine();
statusLine.getReasonPhrase()
你可以简单地得到这样的消息
String message = response.getStatusLine().toString().substring(12);
使用看这个HttpURLConnection
_getResponseMessage()
尝试这个 :
HttpResponse response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
然后把这个输入流转换成字符串......