AndBase开发框架  1.6
 全部  命名空间 文件 函数 变量 枚举值 
| Public 成员函数 | 静态 Public 属性 | 静态 Protected 属性 | Private 成员函数 | Private 属性 | 静态 Private 属性 | 所有成员列表
com.ab.http.AbHttpClient类 参考

class  RedirectionResponseHandler
 
class  ResponderHandler
 

Public 成员函数

 AbHttpClient (Context context)
 
void get (final String url, final AbRequestParams params, final AbHttpResponseListener responseListener)
 
void post (final String url, final AbRequestParams params, final AbHttpResponseListener responseListener)
 
void writeResponseData (Context context, HttpEntity entity, String name, AbFileHttpResponseListener responseListener)
 
void readResponseData (HttpEntity entity, AbBinaryHttpResponseListener responseListener)
 
void setTimeout (int timeout)
 
BasicHttpParams getHttpParams ()
 
HttpClient getHttpClient ()
 
HttpClient createHttpClient ()
 
boolean isOpenEasySSL ()
 
void setOpenEasySSL (boolean isOpenEasySSL)
 
String getUserAgent ()
 
void setUserAgent (String userAgent)
 
String getEncode ()
 
void setEncode (String encode)
 
void shutdown ()
 

静态 Public 属性

static Executor mExecutorService = null
 
static final int DEFAULT_SOCKET_TIMEOUT = 10000
 

静态 Protected 属性

static final int SUCCESS_MESSAGE = 0
 
static final int FAILURE_MESSAGE = 1
 
static final int FAILURE_MESSAGE_CONNECT = 2
 
static final int FAILURE_MESSAGE_SERVICE = 3
 
static final int START_MESSAGE = 4
 
static final int FINISH_MESSAGE = 5
 
static final int PROGRESS_MESSAGE = 6
 
static final int RETRY_MESSAGE = 7
 

Private 成员函数

void doGet (String url, AbRequestParams params, AbHttpResponseListener responseListener)
 
void doPost (String url, AbRequestParams params, AbHttpResponseListener responseListener)
 

Private 属性

String encode = HTTP.UTF_8
 
String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 BIDUBrowser/6.x Safari/537.31"
 
int mTimeout = DEFAULT_SOCKET_TIMEOUT
 
boolean mIsOpenEasySSL = true
 
DefaultHttpClient mHttpClient = null
 
HttpContext mHttpContext = null
 
HttpRequestRetryHandler mRequestRetryHandler
 

静态 Private 属性

static Context mContext
 
static final String HTTP_GET = "GET"
 
static final String HTTP_POST = "POST"
 
static final String USER_AGENT = "User-Agent"
 
static final String ACCEPT_ENCODING = "Accept-Encoding"
 
static final int DEFAULT_MAX_CONNECTIONS = 10
 
static final int DEFAULT_MAX_RETRIES = 3
 
static final int DEFAULT_SOCKET_BUFFER_SIZE = 8192
 
static final int BUFFER_SIZE = 4096
 

详细描述

© 2012 amsoft.cn 名称:AbHttpClient.java 描述:Http客户端

作者
还如一梦中
版本
v1.0
日期
:2013-11-13 上午9:00:52

构造及析构函数说明

com.ab.http.AbHttpClient.AbHttpClient ( Context  context)
inline

初始化.

参数
contextthe context

成员函数说明

HttpClient com.ab.http.AbHttpClient.createHttpClient ( )
inline

获取HttpClient,自签名的证书,如果想做签名参考AuthSSLProtocolSocketFactory类

参数
httpParams
返回
void com.ab.http.AbHttpClient.doGet ( String  url,
AbRequestParams  params,
AbHttpResponseListener  responseListener 
)
inlineprivate

描述:执行get请求.

参数
urlthe url
paramsthe params
responseListenerthe response listener
void com.ab.http.AbHttpClient.doPost ( String  url,
AbRequestParams  params,
AbHttpResponseListener  responseListener 
)
inlineprivate

描述:执行post请求.

参数
urlthe url
paramsthe params
responseListenerthe response listener
void com.ab.http.AbHttpClient.get ( final String  url,
final AbRequestParams  params,
final AbHttpResponseListener  responseListener 
)
inline

描述:带参数的get请求.

参数
urlthe url
paramsthe params
responseListenerthe response listener
String com.ab.http.AbHttpClient.getEncode ( )
inline

获取编码

返回
HttpClient com.ab.http.AbHttpClient.getHttpClient ( )
inline

获取HttpClient,自签名的证书,如果想做签名参考AuthSSLProtocolSocketFactory类

返回
BasicHttpParams com.ab.http.AbHttpClient.getHttpParams ( )
inline

HTTP参数配置

返回
String com.ab.http.AbHttpClient.getUserAgent ( )
inline

获取用户代理

返回
boolean com.ab.http.AbHttpClient.isOpenEasySSL ( )
inline

是否打开ssl 自签名

void com.ab.http.AbHttpClient.post ( final String  url,
final AbRequestParams  params,
final AbHttpResponseListener  responseListener 
)
inline

描述:带参数的post请求.

参数
urlthe url
paramsthe params
responseListenerthe response listener
void com.ab.http.AbHttpClient.readResponseData ( HttpEntity  entity,
AbBinaryHttpResponseListener  responseListener 
)
inline

描述:转换为二进制并回调进度.

参数
entitythe entity
responseListenerthe response listener
void com.ab.http.AbHttpClient.setEncode ( String  encode)
inline

设置编码

参数
encode
void com.ab.http.AbHttpClient.setOpenEasySSL ( boolean  isOpenEasySSL)
inline

打开ssl 自签名

参数
isOpenEasySSL
void com.ab.http.AbHttpClient.setTimeout ( int  timeout)
inline

描述:设置连接超时时间.

参数
timeout毫秒
void com.ab.http.AbHttpClient.setUserAgent ( String  userAgent)
inline

设置用户代理

参数
userAgent
void com.ab.http.AbHttpClient.shutdown ( )
inline

关闭HttpClient

void com.ab.http.AbHttpClient.writeResponseData ( Context  context,
HttpEntity  entity,
String  name,
AbFileHttpResponseListener  responseListener 
)
inline

描述:写入文件并回调进度.

参数
contextthe context
entitythe entity
namethe name
responseListenerthe response listener

类成员变量说明

final String com.ab.http.AbHttpClient.ACCEPT_ENCODING = "Accept-Encoding"
staticprivate
final int com.ab.http.AbHttpClient.BUFFER_SIZE = 4096
staticprivate

缓冲大小.

final int com.ab.http.AbHttpClient.DEFAULT_MAX_CONNECTIONS = 10
staticprivate

最大连接数.

final int com.ab.http.AbHttpClient.DEFAULT_MAX_RETRIES = 3
staticprivate

重试次数.

final int com.ab.http.AbHttpClient.DEFAULT_SOCKET_BUFFER_SIZE = 8192
staticprivate

缓冲大小.

final int com.ab.http.AbHttpClient.DEFAULT_SOCKET_TIMEOUT = 10000
static

超时时间.

String com.ab.http.AbHttpClient.encode = HTTP.UTF_8
private

编码.

final int com.ab.http.AbHttpClient.FAILURE_MESSAGE = 1
staticprotected

失败.

final int com.ab.http.AbHttpClient.FAILURE_MESSAGE_CONNECT = 2
staticprotected

和网络相关的失败.

final int com.ab.http.AbHttpClient.FAILURE_MESSAGE_SERVICE = 3
staticprotected

和服务相关的失败.

final int com.ab.http.AbHttpClient.FINISH_MESSAGE = 5
staticprotected

完成.

final String com.ab.http.AbHttpClient.HTTP_GET = "GET"
staticprivate
final String com.ab.http.AbHttpClient.HTTP_POST = "POST"
staticprivate
Context com.ab.http.AbHttpClient.mContext
staticprivate

上下文.

Executor com.ab.http.AbHttpClient.mExecutorService = null
static

线程执行器.

DefaultHttpClient com.ab.http.AbHttpClient.mHttpClient = null
private

HTTP Client

HttpContext com.ab.http.AbHttpClient.mHttpContext = null
private

HTTP 上下文

boolean com.ab.http.AbHttpClient.mIsOpenEasySSL = true
private

通用证书. 如果要求HTTPS连接,则使用SSL打开连接

HttpRequestRetryHandler com.ab.http.AbHttpClient.mRequestRetryHandler
private

自动重试处理

int com.ab.http.AbHttpClient.mTimeout = DEFAULT_SOCKET_TIMEOUT
private

超时时间.

final int com.ab.http.AbHttpClient.PROGRESS_MESSAGE = 6
staticprotected

进行中.

final int com.ab.http.AbHttpClient.RETRY_MESSAGE = 7
staticprotected

重试.

final int com.ab.http.AbHttpClient.START_MESSAGE = 4
staticprotected

开始.

final int com.ab.http.AbHttpClient.SUCCESS_MESSAGE = 0
staticprotected

成功.

final String com.ab.http.AbHttpClient.USER_AGENT = "User-Agent"
staticprivate
String com.ab.http.AbHttpClient.userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 BIDUBrowser/6.x Safari/537.31"
private

用户代理.


该类的文档由以下文件生成: