-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpHeader.java
More file actions
83 lines (73 loc) · 1.64 KB
/
Copy pathHttpHeader.java
File metadata and controls
83 lines (73 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.hb0730.https;
import com.hb0730.https.utils.CollectionUtils;
import com.hb0730.https.utils.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* http 请求头
*
* @author bing_huang
* @since 1.0.0
*/
public class HttpHeader {
private final Map<String, String> header;
/**
* 构建{@link HttpHeader}
*
* @return {@link HttpHeader}
* @since 2.0.3
*/
public static HttpHeader builder() {
return new HttpHeader();
}
public HttpHeader() {
this.header = new HashMap<>(16);
}
public HttpHeader(Map<String, String> header) {
this.header = header;
}
/**
* 添加请求参数
*
* @param key key
* @param value value
* @return 请求头 this{@link HttpHeader}
*/
public HttpHeader add(String key, String value) {
if (StringUtils.isEmpty(key)) {
return this;
}
this.header.put(key, value);
return this;
}
/**
* 添加请求参数
*
* @param header 请求头参数
* @return 请求头 this{@link HttpHeader}
*/
public HttpHeader addAll(Map<String, String> header) {
if (CollectionUtils.isEmpty(header)) {
return this;
}
this.header.putAll(header);
return this;
}
/**
* 获取请求头
*
* @return 请求头
*/
public Map<String, String> getHeaders() {
return this.header;
}
/**
* 获取请求头
*
* @param key key
* @return 请求参数
*/
public String getHeader(String key) {
return this.header.get(key);
}
}