|
4 | 4 | import java.io.InputStream;
|
5 | 5 | import java.util.Collections;
|
6 | 6 | import java.util.Map;
|
| 7 | +import java.util.Optional; |
7 | 8 | import lombok.Builder;
|
8 | 9 | import lombok.Getter;
|
9 | 10 |
|
10 | 11 | @Builder
|
11 | 12 | public class RequestContentBlock implements WarcContentBlock {
|
12 | 13 |
|
| 14 | + /** |
| 15 | + * the http method used in the request. |
| 16 | + * |
| 17 | + * @see <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods"> |
| 18 | + * https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods</a> |
| 19 | + */ |
13 | 20 | @Getter
|
14 | 21 | private final String method;
|
15 | 22 |
|
| 23 | + /** |
| 24 | + * The target location of the request. |
| 25 | + */ |
16 | 26 | @Getter
|
17 | 27 | private final String location;
|
18 | 28 |
|
| 29 | + /** |
| 30 | + * The payload of the request. |
| 31 | + */ |
19 | 32 | @Getter
|
20 | 33 | private final InputStream payload;
|
21 | 34 |
|
| 35 | + /** |
| 36 | + * The protocol used for the request. |
| 37 | + */ |
22 | 38 | @Getter
|
23 | 39 | private final String protocol;
|
24 | 40 |
|
| 41 | + /** |
| 42 | + * The major protocol version of the request. |
| 43 | + */ |
25 | 44 | @Getter
|
26 | 45 | private final int majorProtocolVersion;
|
27 | 46 |
|
| 47 | + /** |
| 48 | + * The minor protocol version of the request. |
| 49 | + */ |
28 | 50 | @Getter
|
29 | 51 | private final int minorProtocolVersion;
|
30 | 52 |
|
31 | 53 | private final Map<String, String> headers;
|
32 | 54 |
|
33 |
| - public String getHeader(final String headerName) { |
34 |
| - return headers.get(headerName); |
| 55 | + /** |
| 56 | + * Return a value of a header from the request. |
| 57 | + * |
| 58 | + * @param headerName the name of the header to get the value for |
| 59 | + * @return the value of the header |
| 60 | + */ |
| 61 | + public Optional<String> getHeader(final String headerName) { |
| 62 | + return Optional.ofNullable(headers.get(headerName)); |
35 | 63 | }
|
36 | 64 |
|
| 65 | + /** |
| 66 | + * Return all of the headers of a WARC request. |
| 67 | + * |
| 68 | + * @return the headers of the response |
| 69 | + */ |
37 | 70 | public Map<String, String> getHeaders() {
|
38 | 71 | return Collections.unmodifiableMap(headers);
|
39 | 72 | }
|
|
0 commit comments