| 程序包 | 说明 |
|---|---|
| cn.ponfee.commons.http |
| 限定符和类型 | 方法和说明 |
|---|---|
Http |
Http.accept(ContentType contentType)
内容类型发送请求头,告诉服务器什么样的响应会接受返回
header("Accept", contentType)
|
Http |
Http.addHeader(Map<String,String> headers)
设置请求头
|
Http |
Http.addHeader(String name,
String value)
设置请求头
|
Http |
Http.addParam(Map<String,?> params)
最终是拼接成queryString的形式追加到url(即作为get的http请求参数)
get方式会有编码等问题,推荐使用data方式传参数:
data(Map) |
<T> Http |
Http.addParam(String name,
T value) |
Http |
Http.addPart(String formName,
String fileName,
Object mimePart) |
Http |
Http.addPart(String formName,
String fileName,
String contentType,
Object mimePart)
文件上传
|
Http |
Http.connTimeoutSeconds(int seconds)
set connect timeout
|
Http |
Http.contentType(ContentType contentType) |
Http |
Http.contentType(ContentType contentType,
String contentCharset)
请求实体报头,发送信息至服务器时内容编码类型:
multipart/form-data,application/x-www-form-urlencoded,
application/json
默认:application/x-www-form-urlencoded
调用方式:contentType("application/json", "UTF-8")
|
Http |
Http.data(Map<String,?> data)
发送到服务器的查询字符串或json串:name1=value1&name2=value2
|
Http |
Http.data(Map<String,?> data,
String charset)
发送到服务器的查询字符串或json串:name1=value1&name2=value2
application/x-www-form-urlencoded
|
Http |
Http.data(String data)
HttpURLConnection.getOutputStream().write(data)
|
static Http |
Http.delete(String url) |
Http |
Http.encode(Boolean encode)
编码url
|
static Http |
Http.get(String url) |
static Http |
Http.head(String url) |
static Http |
Http.of(String url,
Http.HttpMethod method) |
static Http |
Http.of(String url,
String method) |
static Http |
Http.options(String url) |
static Http |
Http.post(String url) |
static Http |
Http.put(String url) |
Http |
Http.readTimeoutSeconds(int seconds)
set read timeout
|
Http |
Http.setSSLSocketFactory(SSLContext sslContext) |
Http |
Http.setSSLSocketFactory(SSLSocketFactory factory)
trust spec certificate
|
static Http |
Http.trace(String url) |
Copyright © 2023. All rights reserved.