fix comment

This commit is contained in:
Looly
2019-10-09 10:50:26 +08:00
parent ee9a2f70dd
commit 855ff3e2c6
8 changed files with 62 additions and 41 deletions

View File

@@ -1,29 +1,40 @@
package cn.hutool.http;
import java.nio.charset.Charset;
import cn.hutool.core.util.StrUtil;
import java.nio.charset.Charset;
/**
* 常用Content-Type类型枚举
*
*
* @author looly
* @since 4.0.11
*/
public enum ContentType {
/** 标准表单编码当action为get时候浏览器用x-www-form-urlencoded的编码方式把form数据转换成一个字串name1=value1&name2=value2…*/
/**
* 标准表单编码当action为get时候浏览器用x-www-form-urlencoded的编码方式把form数据转换成一个字串name1=value1&name2=value2…
*/
FORM_URLENCODED("application/x-www-form-urlencoded"),
/** 文件上传编码浏览器会把整个表单以控件为单位分割并为每个部分加上Content-Disposition并加上分割符(boundary) */
/**
* 文件上传编码浏览器会把整个表单以控件为单位分割并为每个部分加上Content-Disposition并加上分割符(boundary)
*/
MULTIPART("multipart/form-data"),
/** Rest请求JSON编码 */
/**
* Rest请求JSON编码
*/
JSON("application/json"),
/** Rest请求XML编码 */
/**
* Rest请求XML编码
*/
XML("application/xml"),
/** Rest请求text/xml编码 */
/**
* Rest请求text/xml编码
*/
TEXT_XML("text/xml");
private String value;
ContentType(String value) {
this.value = value;
}
@@ -32,19 +43,20 @@ public enum ContentType {
public String toString() {
return value;
}
/**
* 输出Content-Type字符串附带编码信息
*
* @param charset 编码
* @return Content-Type字符串
*/
public String toString(Charset charset) {
return build(this.value, charset);
}
/**
* 是否为默认Content-Type默认包括<code>null</code>和application/x-www-form-urlencoded
*
*
* @param contentType 内容类型
* @return 是否为默认Content-Type
* @since 4.1.5
@@ -55,7 +67,7 @@ public enum ContentType {
/**
* 是否为application/x-www-form-urlencoded
*
*
* @param contentType 内容类型
* @return 是否为application/x-www-form-urlencoded
*/
@@ -65,12 +77,12 @@ public enum ContentType {
/**
* 从请求参数的body中判断请求的Content-Type类型支持的类型有
*
*
* <pre>
* 1. application/json
* 1. application/xml
* </pre>
*
*
* @param body 请求参数体
* @return Content-Type类型如果无法判断返回null
*/
@@ -79,28 +91,28 @@ public enum ContentType {
if (StrUtil.isNotBlank(body)) {
char firstChar = body.charAt(0);
switch (firstChar) {
case '{':
case '[':
// JSON请求体
contentType = JSON;
break;
case '<':
// XML请求体
contentType = XML;
break;
case '{':
case '[':
// JSON请求体
contentType = JSON;
break;
case '<':
// XML请求体
contentType = XML;
break;
default:
break;
default:
break;
}
}
return contentType;
}
/**
* 输出Content-Type字符串附带编码信息
*
*
* @param contentType Content-Type类型
* @param charset 编码
* @param charset 编码
* @return Content-Type字符串
* @since 4.5.4
*/

View File

@@ -261,6 +261,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
* 设置URL
*
* @param url url字符串
* @return this
* @since 4.1.8
*/
public HttpRequest setUrl(String url) {
@@ -278,6 +279,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
* 相关issue见https://gitee.com/loolly/hutool/issues/IMD1X
*
* @param urlHandler {@link URLStreamHandler}
* @return this
* @since 4.1.9
*/
public HttpRequest setUrlHandler(URLStreamHandler urlHandler) {

View File

@@ -55,6 +55,7 @@ public class Browser extends UserAgentInfo {
*
* @param name 浏览器名称
* @param regex 关键字或表达式
* @param versionRegex 匹配版本的正则
*/
public Browser(String name, String regex, String versionRegex) {
super(name, regex);