Android的:如何获得HttpClient的请求的状态 - code [英] Android: How get the status-code of an HttpClient request

查看:173
本文介绍了Android的:如何获得HttpClient的请求的状态 - code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想下载一个文件,并需要检查响应状态code(即 HTTP /1.1 200 OK )。 这是一个剪断我的code:

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);
...

我如何获得响应的状态 - code?

How do i get the status-code of the response?

推荐答案

这将返回 INT 值:

response.getStatusLine().getStatusCode()

这篇关于Android的:如何获得HttpClient的请求的状态 - code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆