Package | Description |
---|---|
cn.hutool.core.net.url |
URL相关工具
|
cn.hutool.http |
Hutool-http针对JDK的HttpUrlConnection做一层封装,简化了HTTPS请求、文件上传、Cookie记忆等操作,使Http请求变得无比简单。
|
Modifier and Type | Method and Description |
---|---|
UrlBuilder |
UrlBuilder.addPath(CharSequence path)
增加路径,在现有路径基础上追加路径
|
UrlBuilder |
UrlBuilder.addPathSegment(CharSequence segment)
增加路径节点,路径节点中的"/"会被转义为"%2F"
|
UrlBuilder |
UrlBuilder.addQuery(String key,
Object value)
添加查询项,支持重复键
|
UrlBuilder |
UrlBuilder.appendPath(CharSequence path)
Deprecated.
方法重复,请使用
addPath(CharSequence) |
static UrlBuilder |
UrlBuilder.create()
Deprecated.
请使用
of() |
static UrlBuilder |
UrlBuilder.of()
创建空的UrlBuilder
|
static UrlBuilder |
UrlBuilder.of(String url)
使用URL字符串构建UrlBuilder,默认使用UTF-8编码
|
static UrlBuilder |
UrlBuilder.of(String url,
Charset charset)
使用URL字符串构建UrlBuilder
|
static UrlBuilder |
UrlBuilder.of(String scheme,
String host,
int port,
String path,
String query,
String fragment,
Charset charset)
构建UrlBuilder
|
static UrlBuilder |
UrlBuilder.of(String scheme,
String host,
int port,
UrlPath path,
UrlQuery query,
String fragment,
Charset charset)
构建UrlBuilder
|
static UrlBuilder |
UrlBuilder.of(URI uri,
Charset charset)
使用URI构建UrlBuilder
|
static UrlBuilder |
UrlBuilder.of(URL url,
Charset charset)
使用URL构建UrlBuilder
|
static UrlBuilder |
UrlBuilder.ofHttp(String httpUrl)
使用URL字符串构建UrlBuilder,当传入的URL没有协议时,按照http协议对待,编码默认使用UTF-8
|
static UrlBuilder |
UrlBuilder.ofHttp(String httpUrl,
Charset charset)
使用URL字符串构建UrlBuilder,当传入的URL没有协议时,按照http协议对待。
|
static UrlBuilder |
UrlBuilder.ofHttpWithoutEncode(String httpUrl)
使用URL字符串构建UrlBuilder,当传入的URL没有协议时,按照http协议对待
此方法不对URL编码 |
UrlBuilder |
UrlBuilder.setCharset(Charset charset)
设置编码,用于URLEncode和URLDecode
|
UrlBuilder |
UrlBuilder.setFragment(String fragment)
设置标识符,例如#后边的部分
|
UrlBuilder |
UrlBuilder.setHost(String host)
设置主机,例如127.0.0.1
|
UrlBuilder |
UrlBuilder.setPath(UrlPath path)
设置路径,例如/aa/bb/cc,将覆盖之前所有的path相关设置
|
UrlBuilder |
UrlBuilder.setPort(int port)
设置端口,默认-1
|
UrlBuilder |
UrlBuilder.setQuery(UrlQuery query)
设置查询语句,例如a=1&b=2,将覆盖之前所有的query相关设置
|
UrlBuilder |
UrlBuilder.setScheme(String scheme)
设置协议,例如http
|
UrlBuilder |
UrlBuilder.setWithEndTag(boolean withEngTag)
是否path的末尾加 /
|
Modifier and Type | Method and Description |
---|---|
static HttpRequest |
HttpRequest.of(UrlBuilder url)
构建一个HTTP请求
|
HttpRequest |
HttpRequest.setUrl(UrlBuilder urlBuilder)
设置URL
|
Constructor and Description |
---|
HttpRequest(UrlBuilder url)
构造
|
Copyright © 2024. All rights reserved.