-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestHeader.java
More file actions
31 lines (25 loc) · 792 Bytes
/
RequestHeader.java
File metadata and controls
31 lines (25 loc) · 792 Bytes
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
package WebServer;
import java.util.HashMap;
import java.io.BufferedReader;
public class RequestHeader {
private HashMap<String, String> headers;
public RequestHeader(BufferedReader request) throws Exception {
this.headers = new HashMap<>();
String temp;
while (!((temp = request.readLine()).isEmpty())) {
String[] headerParts = temp.split(":");
this.put(headerParts[0].trim(), headerParts[1].trim());
}
}
private void put(String key, String val) {
this.headers.put(key, val);
}
public String getVal(String key) {
return this.headers.get(key);
}
public void display() {
this.headers.forEach((k, v) -> {
System.out.printf("%s : %s \n", k, v);
});
}
}