Package | Description |
---|---|
cn.hutool.http |
Hutool-http针对JDK的HttpUrlConnection做一层封装,简化了HTTPS请求、文件上传、Cookie记忆等操作,使Http请求变得无比简单。
|
cn.hutool.http.cookie |
自定义Cookie
|
Modifier and Type | Field and Description |
---|---|
protected HttpConnection |
HttpResponse.httpConnection
持有连接对象
|
Modifier and Type | Method and Description |
---|---|
HttpConnection |
HttpConnection.connect()
连接
|
static HttpConnection |
HttpConnection.create(String urlStr,
Proxy proxy)
创建HttpConnection
|
static HttpConnection |
HttpConnection.create(URL url,
Proxy proxy)
创建HttpConnection
|
HttpConnection |
HttpConnection.disableCache()
关闭缓存
|
HttpConnection |
HttpConnection.disconnect()
断开连接
|
HttpConnection |
HttpConnection.disconnectQuietly()
静默断开连接。
|
HttpConnection |
HttpRequest.getConnection()
|
HttpConnection |
HttpConnection.header(Header header,
String value,
boolean isOverride)
设置请求头
当请求头存在时,覆盖之 |
HttpConnection |
HttpConnection.header(Map<String,List<String>> headerMap,
boolean isOverride)
设置请求头
不覆盖原有请求头 |
HttpConnection |
HttpConnection.header(String header,
String value,
boolean isOverride)
设置请求头
当请求头存在时,覆盖之 |
HttpConnection |
HttpConnection.initConn()
初始化连接相关信息
|
HttpConnection |
HttpConnection.setChunkedStreamingMode(int blockSize)
采用流方式上传数据,无需本地缓存数据。
|
HttpConnection |
HttpConnection.setConnectionAndReadTimeout(int timeout)
设置连接和读取的超时时间
|
HttpConnection |
HttpConnection.setConnectTimeout(int timeout)
设置连接超时
|
HttpConnection |
HttpConnection.setCookie(String cookie)
设置Cookie
|
HttpConnection |
HttpConnection.setFixedLengthStreamingMode(long contentLength)
设置固定长度的流模式,会设置HTTP请求头中的Content-Length字段,告知服务器整个请求体的精确字节大小。
|
HttpConnection |
HttpConnection.setHttpsInfo(HostnameVerifier hostnameVerifier,
SSLSocketFactory ssf)
设置https请求参数
有些时候htts请求会出现com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl的实现,此为sun内部api,按照普通http请求处理 |
HttpConnection |
HttpConnection.setInstanceFollowRedirects(boolean isInstanceFollowRedirects)
设置自动HTTP 30X跳转
|
HttpConnection |
HttpConnection.setMethod(Method method)
设置请求方法
|
HttpConnection |
HttpConnection.setReadTimeout(int timeout)
设置读取超时
|
Constructor and Description |
---|
HttpResponse(HttpConnection httpConnection,
HttpConfig config,
Charset charset,
boolean isAsync,
boolean isIgnoreBody)
构造
|
Modifier and Type | Method and Description |
---|---|
static void |
GlobalCookieManager.add(HttpConnection conn)
将本地存储的Cookie信息附带到Http请求中,不覆盖用户定义好的Cookie
|
static List<HttpCookie> |
GlobalCookieManager.getCookies(HttpConnection conn)
获取指定域名下所有Cookie信息
|
static void |
GlobalCookieManager.store(HttpConnection conn)
存储响应的Cookie信息到本地
|
Copyright © 2024. All rights reserved.