Android:如何获取 HttpClient 请求的状态代码
我想下载一个文件,需要检查响应状态代码(即HTTP /1.1 200 OK
)。 这是我的代码的片段:
HttpGet httpRequest = new HttpGet(myUri);
HttpEntity httpEntity = null;
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httpRequest);
...
如何获取响应的状态代码?
I want to download a file and need to check the response status code (ie HTTP /1.1 200 OK
).
This is a snipped of my code:
HttpGet httpRequest = new HttpGet(myUri);
HttpEntity httpEntity = null;
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httpRequest);
...
How do i get the status-code of the response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这将返回
int
值:This will return the
int
value:使用response的
code()
函数来获取它的HTTP代码:Use
code()
function of response to get its HTTP code: