public class Httper extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected String |
bodyStr |
protected Charset |
charset |
protected int |
connectTimeout |
protected String |
contentType |
protected Map<String,Object> |
cookies |
protected boolean |
debug |
protected Map<String,Map<String,Object>> |
fileStreams |
protected Map<String,String> |
headers |
protected static org.slf4j.Logger |
log |
protected String |
method |
protected Map<String,Object> |
params |
protected Consumer<HttpURLConnection> |
preFn |
protected int |
readTimeout |
protected int |
respCode |
protected String |
tlsVersion |
protected String |
urlStr |
| 构造器和说明 |
|---|
Httper() |
| 限定符和类型 | 方法和说明 |
|---|---|
Httper |
charset(String charset) |
Httper |
connectTimeout(int timeout) |
Httper |
contentType(String contentType)
设置 content-type
|
Httper |
cookie(String name,
Object value) |
Map<String,Object> |
cookies() |
Httper |
debug() |
Httper |
delete(String url) |
String |
execute()
执行 http 请求
|
Httper |
fileStream(String pName,
String filename,
InputStream fileStream)
添加文件流
|
Httper |
get(String url) |
int |
getResponseCode() |
Httper |
header(String name,
String value) |
Httper |
jsonBody(String jsonStr) |
Httper |
param(String name,
Object value)
添加参数
|
Httper |
post(String url) |
Httper |
preConnect(Consumer<HttpURLConnection> preConnect) |
Httper |
put(String url) |
Httper |
readTimeout(int timeout) |
Httper |
textBody(String bodyStr) |
Httper |
tlsVersion(String tlsVersion) |
protected static final org.slf4j.Logger log
protected String urlStr
protected String contentType
protected String method
protected String bodyStr
protected int connectTimeout
protected int readTimeout
protected int respCode
protected Consumer<HttpURLConnection> preFn
protected boolean debug
protected String tlsVersion
protected Charset charset
public Httper contentType(String contentType)
contentType - application/json, multipart/form-data, application/x-www-form-urlencoded, text/plainpublic Httper readTimeout(int timeout)
public Httper connectTimeout(int timeout)
public Httper preConnect(Consumer<HttpURLConnection> preConnect)
public Httper debug()
public Httper fileStream(String pName, String filename, InputStream fileStream)
pName - 属性名filename - 文件名fileStream - 文件流public int getResponseCode()
public String execute()
Copyright © 2022. All rights reserved.