mirror of https://github.com/apache/nifi.git
NIFI-12383 Replication client should handle accept encoding with lowercase
Signed-off-by: Bence Simon <bsimon@apache.org> This closes #8043
This commit is contained in:
parent
9cfdebc3e8
commit
63364687d8
|
@ -291,7 +291,11 @@ public class OkHttpReplicationClient implements HttpReplicationClient {
|
|||
|
||||
|
||||
private boolean isUseGzip(final Map<String, String> headers) {
|
||||
final String rawAcceptEncoding = headers.get(HttpHeaders.ACCEPT_ENCODING);
|
||||
String rawAcceptEncoding = headers.get(HttpHeaders.ACCEPT_ENCODING);
|
||||
|
||||
if (rawAcceptEncoding == null) {
|
||||
rawAcceptEncoding = headers.get(HttpHeaders.ACCEPT_ENCODING.toLowerCase());
|
||||
}
|
||||
|
||||
if (rawAcceptEncoding == null) {
|
||||
return false;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.nifi.cluster.coordination.http.replication.okhttp;
|
||||
|
||||
import org.apache.nifi.cluster.coordination.http.replication.PreparedRequest;
|
||||
import org.apache.nifi.security.util.TemporaryKeyStoreBuilder;
|
||||
import org.apache.nifi.security.util.TlsConfiguration;
|
||||
import org.apache.nifi.util.NiFiProperties;
|
||||
|
@ -100,6 +101,25 @@ public class OkHttpReplicationClientTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldReadCasInsensitiveAcceptEncoding() {
|
||||
final Map<String, String> headers = new HashMap<>();
|
||||
headers.put("accept-encoding", "gzip");
|
||||
headers.put("Other-Header", "arbitrary value");
|
||||
|
||||
final NiFiProperties mockProperties = mockNiFiProperties();
|
||||
|
||||
final OkHttpReplicationClient client = new OkHttpReplicationClient(mockProperties);
|
||||
|
||||
|
||||
PreparedRequest request = client.prepareRequest("POST", headers, "TEST");
|
||||
|
||||
assertEquals(3, request.getHeaders().size());
|
||||
assertEquals("gzip", request.getHeaders().get("accept-encoding"));
|
||||
assertEquals("gzip", request.getHeaders().get("Content-Encoding"));
|
||||
assertEquals("arbitrary value", request.getHeaders().get("Other-Header"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldUseKeystorePasswordIfKeyPasswordIsBlank() {
|
||||
final Map<String, String> propsMap = new HashMap<>();
|
||||
|
|
Loading…
Reference in New Issue