| 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

初始化.

参数

  context | the context

## 成员函数说明

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

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

参数

  httpParams |

返回

void com.ab.http.AbHttpClient.doGet | ( | String | url,
|  | AbRequestParams | params,
|  | AbHttpResponseListener | responseListener
| ) |  |
| inline private

描述：执行get请求.

参数

  url | the url
  params | the params
  responseListener | the response listener

void com.ab.http.AbHttpClient.doPost | ( | String | url,
|  | AbRequestParams | params,
|  | AbHttpResponseListener | responseListener
| ) |  |
| inline private

描述：执行post请求.

参数

  url | the url
  params | the params
  responseListener | the response listener

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

描述：带参数的get请求.

参数

  url | the url
  params | the params
  responseListener | the 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请求.

参数

  url | the url
  params | the params
  responseListener | the response listener

void com.ab.http.AbHttpClient.readResponseData | ( | HttpEntity | entity,
|  | AbBinaryHttpResponseListener | responseListener
| ) |  |
| inline

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

参数

  entity | the entity
  responseListener | the 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

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

参数

  context | the context
  entity | the entity
  name | the name
  responseListener | the response listener

## 类成员变量说明

final String com.ab.http.AbHttpClient.ACCEPT_ENCODING = "Accept-Encoding"
| static private

final int com.ab.http.AbHttpClient.BUFFER_SIZE = 4096
| static private

缓冲大小.

final int com.ab.http.AbHttpClient.DEFAULT_MAX_CONNECTIONS = 10
| static private

最大连接数.

final int com.ab.http.AbHttpClient.DEFAULT_MAX_RETRIES = 3
| static private

重试次数.

final int com.ab.http.AbHttpClient.DEFAULT_SOCKET_BUFFER_SIZE = 8192
| static private

缓冲大小.

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
| static protected

失败.

final int com.ab.http.AbHttpClient.FAILURE_MESSAGE_CONNECT = 2
| static protected

和网络相关的失败.

final int com.ab.http.AbHttpClient.FAILURE_MESSAGE_SERVICE = 3
| static protected

和服务相关的失败.

final int com.ab.http.AbHttpClient.FINISH_MESSAGE = 5
| static protected

完成.

final String com.ab.http.AbHttpClient.HTTP_GET = "GET"
| static private

final String com.ab.http.AbHttpClient.HTTP_POST = "POST"
| static private

Context com.ab.http.AbHttpClient.mContext
| static private

上下文.

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
| static protected

进行中.

final int com.ab.http.AbHttpClient.RETRY_MESSAGE = 7
| static protected

重试.

final int com.ab.http.AbHttpClient.START_MESSAGE = 4
| static protected

开始.

final int com.ab.http.AbHttpClient.SUCCESS_MESSAGE = 0
| static protected

成功.

final String com.ab.http.AbHttpClient.USER_AGENT = "User-Agent"
| static private

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

用户代理.

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

- src/com/ab/http/AbHttpClient.java