| 构造器和说明 |
|---|
HttpUtil()
默认构造函数
|
HttpUtil(String charset)
构造函数 设置编码
|
HttpUtil(String ip,
int port)
构造函数,设置代理
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
关闭连接
|
ResponseInfo |
get(Map<String,String> headers,
String url)
根据header url发起get请求
|
ResponseInfo |
get(String url)
根据url发起get请求
|
Map<String,String> |
getCommonHeader()
默认的header信息
Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:zh-CN,zh;q=0.8 User-Agent:Q-Test-Automation-Framework-QTAF/1.0.0 Apache-HttpClient/4.2.5 (java 1.7) Accept:* Content-Type:application/x-www-form-urlencoded; charset=utf-8 |
byte[] |
getFile(Map<String,String> headers,
String url,
File file)
get方式下载文件 返回字节
|
String |
getFile(Map<String,String> headers,
String url,
String enCoding)
get方式下载文件,以字符串方式显示
|
ResponseInfo |
post(TreeMap<String,String> headers,
String url,
String str)
设置发送请求的headers,url,str信息,发送post请求,得到返回的字符串结果集
|
ResponseInfo |
post(TreeMap<String,String> headers,
String url,
TreeMap<String,Object> params)
设置发送请求的header,url,params信息,发送post请求,得到返回的字符串结果集
|
void |
setCharset(String charset)
设置编码
|
protected LogUtil log
public HttpUtil()
public HttpUtil(String charset)
charset - public HttpUtil(String ip, int port)
ip - port - public ResponseInfo get(Map<String,String> headers, String url)
headers - url - public ResponseInfo get(String url)
url - public ResponseInfo post(TreeMap<String,String> headers, String url, TreeMap<String,Object> params)
headers - url - params - public ResponseInfo post(TreeMap<String,String> headers, String url, String str)
headers - url - str - public String getFile(Map<String,String> headers, String url, String enCoding)
headers - url - public byte[] getFile(Map<String,String> headers, String url, File file)
headers - url - file - public void close()
public void setCharset(String charset)
charset - public Map<String,String> getCommonHeader()
Copyright © 2013. All Rights Reserved.