Skip to content

Commit 8a18b2a

Browse files
committed
Update HttpOpener Content-Encoding header constant name and JavaDoc. (#513)
Also, group constants.
1 parent c55cbe0 commit 8a18b2a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

metafacture-io/src/main/java/org/metafacture/io/HttpOpener.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,30 @@
5353
@FluxCommand("open-http")
5454
public final class HttpOpener extends DefaultObjectPipe<String, ObjectReceiver<Reader>> {
5555

56-
public static final String ACCEPT_DEFAULT = "*/*";
5756
public static final String ACCEPT_HEADER = "accept";
58-
public static final String CONTENT_TYPE_HEADER = "content-type";
57+
public static final String ACCEPT_CHARSET_HEADER = "accept-charset";
5958
public static final String ACCEPT_ENCODING_HEADER = "accept-encoding";
60-
public static final String ENCODING_HEADER = "content-encoding";
61-
public static final String DEFAULT_PREFIX = "ERROR: ";
59+
public static final String CONTENT_ENCODING_HEADER = "content-encoding";
60+
public static final String CONTENT_TYPE_HEADER = "content-type";
61+
62+
public static final String ACCEPT_DEFAULT = "*/*";
6263
public static final String CHARSET_DEFAULT = "UTF-8";
63-
public static final String ACCEPT_CHARSET_HEADER = "accept-charset";
64+
public static final String DEFAULT_PREFIX = "ERROR: ";
65+
public static final String HEADER_FIELD_SEPARATOR = "\n";
66+
public static final String HEADER_VALUE_SEPARATOR = ":";
6467
public static final String INPUT_DESIGNATOR = "@-";
68+
6569
public static final String DEFAULT_METHOD_NAME = "GET";
6670
public static final Method DEFAULT_METHOD = Method.valueOf(DEFAULT_METHOD_NAME);
67-
public static final String HEADER_FIELD_SEPARATOR = "\n";
68-
public static final String HEADER_VALUE_SEPARATOR = ":";
71+
6972
private static final Pattern HEADER_FIELD_SEPARATOR_PATTERN = Pattern.compile(HEADER_FIELD_SEPARATOR);
7073
private static final Pattern HEADER_VALUE_SEPARATOR_PATTERN = Pattern.compile(HEADER_VALUE_SEPARATOR);
74+
7175
private static final int ALLOWED_REDIRECTIONS = 3;
7276
private static final int CONNECTION_TIMEOUT = 11000;
77+
7378
private final Map<String, String> headers = new HashMap<>();
79+
7480
private Method method;
7581
private String body;
7682
private String errorPrefix;
@@ -199,16 +205,16 @@ public void setAcceptContentEncoding(final String contentEncoding) {
199205
}
200206

201207
/**
202-
* Sets the HTTP {@value ENCODING_HEADER} header value. This is the
203-
* content encoding for the HTTP GET. It enables HTTP compression.
208+
* Sets the HTTP {@value CONTENT_ENCODING_HEADER} header value. This is the
209+
* content encoding for the HTTP request. It enables HTTP compression.
204210
* Allowed values are "gzip".
205211
* The default for the content encoding is null, which means "no compression".
206212
*
207213
* @param contentEncoding name of content encoding used for the content-encoding HTTP
208214
* header
209215
*/
210216
public void setContentEncoding(final String contentEncoding) {
211-
setHeader(ENCODING_HEADER, contentEncoding);
217+
setHeader(CONTENT_ENCODING_HEADER, contentEncoding);
212218
}
213219

214220
/**

metafacture-io/src/test/java/org/metafacture/io/HttpOpenerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public void shouldPerformGetRequestWithErrorResponseAndWithoutErrorPrefixParamet
278278
public void shouldPerformGetRequestWithGzipedContentEncoding() throws IOException {
279279
shouldPerformRequest(TEST_URL, HttpOpener.Method.GET, (o, u) -> o.setAcceptContentEncoding("gzip"),
280280
null, null,
281-
WireMock.ok().withBody(GZIPPED_RESPONSE_BODY).withHeaders(new HttpHeaders(new HttpHeader(HttpOpener.ENCODING_HEADER,"gzip"))),
281+
WireMock.ok().withBody(GZIPPED_RESPONSE_BODY).withHeaders(new HttpHeaders(new HttpHeader(HttpOpener.CONTENT_ENCODING_HEADER,"gzip"))),
282282
RESPONSE_BODY);
283283
}
284284

0 commit comments

Comments
 (0)