Skip to content

Commit

Permalink
Merge #2501 into 2.0.0-M2
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Sep 23, 2022
2 parents 5658c34 + cb3d261 commit d97bcb0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Expand Up @@ -30,8 +30,8 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_CONNECTION_NAME;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_CONNECTION_VALUE;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_TEST_NAME;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_TEST_VALUE;
import static reactor.netty5.http.server.logging.LoggingTests.URI;


Expand All @@ -45,7 +45,7 @@ class AccessLogArgProviderH2Tests {

static {
Http2Headers requestHttpHeaders = new DefaultHttp2Headers(2, true, true, true);
requestHttpHeaders.add(HEADER_CONNECTION_NAME, HEADER_CONNECTION_VALUE);
requestHttpHeaders.add(HEADER_TEST_NAME, HEADER_TEST_VALUE);
requestHttpHeaders.method(HttpMethod.GET.name());
requestHttpHeaders.path(URI);
requestHeaders = new DefaultHttp2HeadersFrame(requestHttpHeaders);
Expand Down Expand Up @@ -94,10 +94,10 @@ void protocol() {
@Test
void requestHeader() {
assertThatNullPointerException().isThrownBy(() -> accessLogArgProvider.requestHeader(null));
assertThat(accessLogArgProvider.requestHeader(HEADER_CONNECTION_NAME)).isNull();
assertThat(accessLogArgProvider.requestHeader(HEADER_TEST_NAME)).isNull();
accessLogArgProvider.requestHeaders(requestHeaders);
assertThat(accessLogArgProvider.requestHeader(HEADER_CONNECTION_NAME))
.isEqualTo(HEADER_CONNECTION_VALUE);
assertThat(accessLogArgProvider.requestHeader(HEADER_TEST_NAME))
.isEqualTo(HEADER_TEST_VALUE);
}

@Test
Expand Down
Expand Up @@ -28,8 +28,8 @@
import java.net.SocketAddress;

import static org.assertj.core.api.Assertions.assertThat;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_CONNECTION_NAME;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_CONNECTION_VALUE;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_TEST_NAME;
import static reactor.netty5.http.server.logging.LoggingTests.HEADER_TEST_VALUE;
import static reactor.netty5.http.server.logging.LoggingTests.RESPONSE_CONTENT;
import static reactor.netty5.http.server.logging.LoggingTests.URI;

Expand All @@ -44,14 +44,14 @@ void accessLogArgs() {
channel.pipeline().addLast(new AccessLogHandlerH2(
args -> {
assertAccessLogArgProvider(args, channel.remoteAddress());
return AccessLog.create("{}={}", HEADER_CONNECTION_NAME,
args.requestHeader(HEADER_CONNECTION_NAME));
return AccessLog.create("{}={}", HEADER_TEST_NAME,
args.requestHeader(HEADER_TEST_NAME));
}));

Http2Headers requestHeaders = new DefaultHttp2Headers(2, true, true, true);
requestHeaders.method(HttpMethod.GET.name());
requestHeaders.path(URI);
requestHeaders.add(HEADER_CONNECTION_NAME, HEADER_CONNECTION_VALUE);
requestHeaders.add(HEADER_TEST_NAME, HEADER_TEST_VALUE);
channel.writeInbound(new DefaultHttp2HeadersFrame(requestHeaders));

Http2Headers responseHeaders = new DefaultHttp2Headers(1, true, true, true);
Expand All @@ -72,7 +72,7 @@ private void assertAccessLogArgProvider(AccessLogArgProvider args, SocketAddress
assertThat(args.protocol()).isEqualTo(AccessLogArgProviderH2.H2_PROTOCOL_NAME);
assertThat(args.status()).isEqualTo(HttpResponseStatus.OK.codeAsText());
assertThat(args.contentLength()).isEqualTo(RESPONSE_CONTENT.length);
assertThat(args.requestHeader(HEADER_CONNECTION_NAME)).isEqualTo(HEADER_CONNECTION_VALUE);
assertThat(args.requestHeader(HEADER_TEST_NAME)).isEqualTo(HEADER_TEST_VALUE);
}

}
Expand Up @@ -28,6 +28,8 @@ class LoggingTests {

static final CharSequence HEADER_CONNECTION_NAME = HttpHeaderNames.CONNECTION;
static final String HEADER_CONNECTION_VALUE = "keep-alive";
static final CharSequence HEADER_TEST_NAME = "test";
static final String HEADER_TEST_VALUE = "test";
static final String URI = "/hello";
static final byte[] RESPONSE_CONTENT = "Hello".getBytes(StandardCharsets.UTF_8);

Expand Down

0 comments on commit d97bcb0

Please sign in to comment.