Skip to content

Commit

Permalink
Merge pull request #146 from nicmunroe/feature/dependency-update
Browse files Browse the repository at this point in the history
Feature/dependency update
  • Loading branch information
nicmunroe authored Mar 1, 2022
2 parents 5dbb20a + 6974251 commit 647390a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

34 changes: 18 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,32 @@ javadocJar.enabled = false
// ========== PROPERTIES FOR GRADLE BUILD - DEPENDENCY VERSIONS / ETC
ext {
// DEPENDENCY VERSIONS
// Core and multi-module dependencies
nettyVersion = '4.1.49.Final'
slf4jVersion = '1.7.30'
jetbrainsAnnotationsVersion = '19.0.0'
jacksonVersion = '2.11.0'
wingtipsVersion = '0.23.0'
backstopperVersion = '0.13.0'
// ====== Core and multi-module dependencies
nettyVersion = '4.1.74.Final'
slf4jVersion = '1.7.36'
jacksonVersion = '2.13.1'
wingtipsVersion = '0.24.2'
backstopperVersion = '0.14.1'
fastbreakVersion = '0.10.3'

// Misc module dependencies
// ====== Misc module dependencies
ningAsyncHttpClientVersion = '1.9.40'
asyncHttpClientVersion = '2.12.1'
asyncHttpClientVersion = '2.12.3'
servletApiVersion = '3.1.0'
guiceVersion = '4.2.3'
codahaleMetricsVersion = '4.1.6'
signalFxCodahaleVersion = '1.0.3'
eurekaClientVersion = '1.9.21'
codahaleMetricsVersion = '4.2.8'
signalFxCodahaleVersion = '1.0.14'
eurekaClientVersion = '1.10.17'
archaiusVersion = '0.7.7'
apacheCommonsConfigurationVersion = '1.8'
typesafeConfigVersion = '1.4.0'
apacheCommonsConfigurationVersion = '1.10'
typesafeConfigVersion = '1.4.2'

// ====== Compile-only dependencies
jetbrainsAnnotationsVersion = '19.0.0'

// ====== Test dependencies
junit5Version = '5.6.2'
junitVersion = '4.13'
junit5Version = '5.8.2'
junitVersion = '4.13.2'
junitDataproviderVersion = '1.13.1'
assertJVersion = '3.15.0'
mockitoVersion = '3.3.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,8 @@ private enum AlwaysEmptyResponseScenario {
@DataProvider(value = {
"STATUS_204_RESPONSE | true",
"STATUS_204_RESPONSE | false",
// Currently, Netty appears to not handle 205 properly at all when encoding responses where a payload is
// specified, so we'll just disable these 205 scenarios for now until that gets fixed.
// See this Netty issue: https://github.com/netty/netty/issues/7888
// "STATUS_205_RESPONSE | true",
// "STATUS_205_RESPONSE | false",
"STATUS_205_RESPONSE | true",
"STATUS_205_RESPONSE | false",
"STATUS_304_RESPONSE | true",
"STATUS_304_RESPONSE | false",
"HEAD_REQUEST | true",
Expand Down Expand Up @@ -317,7 +314,15 @@ public void proxy_endpoints_should_handle_always_empty_response_scenarios_correc

// Now we know that downstream and proxy response had matching content-length header, so we can move on
// to verifying the value of that header.
if (isChunkedResponse || scenario.responseStatusCode == 204) {
if (scenario.responseStatusCode == 205) {
// Netty treats 205 special - it strips any payload and transfer-encoding header, and sets
// content-length to 0. So even though we ask for a chunked response (which would normally lead to
// null content-length response header), we end up with content-length header equal to zero.
// See this Netty PR and issue: https://github.com/netty/netty/pull/7891
// and https://github.com/netty/netty/issues/7888
assertThat(proxyResponseContentLengthHeader).isEqualTo("0");
}
else if (isChunkedResponse || scenario.responseStatusCode == 204) {
// Chunked responses will never have content-length header defined, and
// 204 is special - it should never have content-length returned regardless of transfer encoding.
assertThat(proxyResponseContentLengthHeader).isNull();
Expand Down Expand Up @@ -471,9 +476,9 @@ private void verifyProxyAndDownstreamRequestHeaders() {
// Verify that the proxy and downstream requests have the same headers (barring the tracing headers and the
// host header, which can be different between proxy and downstream and we've already accounted for above).
Map<String, List<String>> normalizedProxyHeaders =
headersToMap(copyWithMutableHeadersRemoved(proxyRequestHeaders));
headersToMap(copyWithMutableHeadersRemoved(proxyRequestHeaders), true);
Map<String, List<String>> normalizedDownstreamHeaders =
headersToMap(copyWithMutableHeadersRemoved(downstreamRequestHeaders));
headersToMap(copyWithMutableHeadersRemoved(downstreamRequestHeaders), true);
assertThat(normalizedProxyHeaders).isEqualTo(normalizedDownstreamHeaders);
}

Expand Down Expand Up @@ -510,19 +515,19 @@ private void verifyProxyAndDownstreamResponseHeaders(boolean expectProxyToRemove
// Verify that the proxy and downstream requests have the same headers (barring the trace ID header, which can
// be added by the proxy and we've already accounted for above).
Map<String, List<String>> normalizedProxyHeaders =
headersToMap(copyWithMutableHeadersRemoved(proxyResponseHeaders));
headersToMap(copyWithMutableHeadersRemoved(proxyResponseHeaders), true);
Map<String, List<String>> normalizedDownstreamHeaders =
headersToMap(copyWithMutableHeadersRemoved(downstreamResponseHeaders));
headersToMap(copyWithMutableHeadersRemoved(downstreamResponseHeaders), true);

if (expectProxyToRemoveTransferEncoding) {
List<String> downstreamTransferEncodingValue = normalizedDownstreamHeaders.get(TRANSFER_ENCODING);
List<String> downstreamTransferEncodingValue = normalizedDownstreamHeaders.get(TRANSFER_ENCODING.toLowerCase());

if (downstreamTransferEncodingValue != null) {
// For the purpose of testing equality we'll set the proxy headers to include whatever downstream had
// for transfer-encoding. This is because the Netty correctly stripped that header on the proxy
// when it received the response. By adding this back to the proxy headers we can then do a normal
// equality check in order to verify the other headers.
normalizedProxyHeaders.put(TRANSFER_ENCODING, normalizedDownstreamHeaders.get(TRANSFER_ENCODING));
normalizedProxyHeaders.put(TRANSFER_ENCODING.toLowerCase(), downstreamTransferEncodingValue);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,15 @@ public static HttpHeaders extractHeadersFromRawRequestOrResponse(String rawReque
}

public static Map<String, List<String>> headersToMap(HttpHeaders headers) {
return headersToMap(headers, false);
}

public static Map<String, List<String>> headersToMap(HttpHeaders headers, boolean lowercaseNormalizeNames) {
Map<String, List<String>> result = new LinkedHashMap<>();
headers.names().forEach(headerKey -> result.put(headerKey, headers.getAll(headerKey)));
headers.names().forEach(headerKey -> {
String headerKeyToUse = (lowercaseNormalizeNames) ? headerKey.toLowerCase() : headerKey;
result.put(headerKeyToUse, headers.getAll(headerKey));
});
return result;
}
}

0 comments on commit 647390a

Please sign in to comment.