0

我收到这样的回复:

HttpResponse response = httpclient.execute(httpget);
response.getStatusLine().toString());

在这种情况下,响应是:

HTTP/1.1 500 invalid user credentials

何我只收到消息,没有代码?

**invalid user credentials**
4

6 回答 6

1

尝试这个:

HttpResponse response = httpclient.execute(httpget);
StatusLine statusLine = response.getStatusLine();

String messageOnly = statusLine.getReasonPhrase();
int codeOnly = statusLine.getStatusCode();
于 2013-02-27T08:09:47.507 回答
1

很简单,这样做

String responseStr = EntityUtils.toString(response.getEntity());

这会奏效!

于 2013-02-27T08:52:52.033 回答
0

使用 StatusLine 接口的 getReasonPhrase() 方法。例如

HttpResponse response = httpclient.execute(httpget);
StatusLine statusLine = response.getStatusLine();
 statusLine.getReasonPhrase()
于 2013-02-27T09:44:00.143 回答
0

你可以简单地得到这样的消息

         String message = response.getStatusLine().toString().substring(12);
于 2013-02-27T07:54:08.050 回答
0

使用看这个HttpURLConnection_getResponseMessage()

于 2013-02-27T07:56:00.520 回答
0

尝试这个 :

HttpResponse response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent(); 

然后把这个输入流转换成字符串......

于 2013-02-27T08:15:15.017 回答