Skip to content

Commit

Permalink
Rebase fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkec committed Sep 13, 2023
1 parent c0639f0 commit ddf6976
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.helidon.http.ClientResponseHeaders;
import io.helidon.http.Header;
import io.helidon.http.HeaderNames;
import io.helidon.http.HeaderName;
import io.helidon.http.Headers;
import io.helidon.http.HttpMediaType;
import io.helidon.http.Method;
Expand Down Expand Up @@ -137,7 +138,7 @@ public void testInvalidContentType() {
ClientResponseHeaders h = res.headers();
Header contentType = h.get(HeaderNames.CONTENT_TYPE);
assertThat(res.status(), is(Status.OK_200));
assertThat(contentType.value(), is(INVALID_CONTENT_TYPE_VALUE));
assertThat(contentType.get(), is(INVALID_CONTENT_TYPE_VALUE));
}
}

Expand All @@ -151,7 +152,7 @@ public void testInvalidTextContentTypeStrict() {
Headers h = res.headers();
// Raw protocol data value
Header rawContentType = h.get(HeaderNames.CONTENT_TYPE);
assertThat(rawContentType.value(), is(INVALID_CONTENT_TYPE_TEXT));
assertThat(rawContentType.get(), is(INVALID_CONTENT_TYPE_TEXT));
// Media type parsed value is invalid, IllegalArgumentException shall be thrown
try {
Optional<HttpMediaType> httpMediaType = h.contentType();
Expand All @@ -166,7 +167,7 @@ public void testInvalidTextContentTypeStrict() {
@Test
public void testInvalidTextContentTypeRelaxed() {
WebClient client = WebClient.builder()
.from(this.client.prototype())
.from(HeadersTest.client.prototype())
.mediaTypeParserMode(ParserMode.RELAXED)
.build();
try (HttpClientResponse res = client.method(Method.GET)
Expand All @@ -176,7 +177,7 @@ public void testInvalidTextContentTypeRelaxed() {
Headers h = res.headers();
// Raw protocol data value
Header rawContentType = h.get(HeaderNames.CONTENT_TYPE);
assertThat(rawContentType.value(), is(INVALID_CONTENT_TYPE_TEXT));
assertThat(rawContentType.get(), is(INVALID_CONTENT_TYPE_TEXT));
// Media type parsed value
Optional<HttpMediaType> contentType = h.contentType();
assertThat(contentType.isPresent(), is(true));
Expand All @@ -200,7 +201,7 @@ void trailerHeader() {

assertThat(h.first(HeaderNames.create("test")).orElse(null), is("before"));

assertThrows(IllegalStateException.class, () -> res.trailers());
assertThrows(IllegalStateException.class, res::trailers);
assertThat(res.as(String.class), is(DATA));
Headers t = res.trailers();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -155,7 +154,7 @@ void trailerHeader() {
Headers h = res.headers();
assertThat(h.first(HeaderNames.create("test")).orElse(null), is("before"));

assertThrows(IllegalStateException.class, () -> res.trailers());
assertThrows(IllegalStateException.class, res::trailers);
assertThat(res.as(String.class), is(DATA));
Optional<String> header = res.trailers().first(HeaderNames.create("Trailer-header"));
assertTrue(header.isPresent());
Expand All @@ -167,12 +166,12 @@ void trailerHeader() {
@Test
void noTrailerHeader() {
try (Http2ClientResponse res = client
.method(Http.Method.GET)
.method(Method.GET)
.path("/no-trailer")
.priorKnowledge(true)
.request()) {
Headers h = res.headers();
assertThat(h.first(Http.HeaderNames.create("test")).orElse(null), is("before"));
assertThat(h.first(HeaderNames.create("test")).orElse(null), is("before"));
assertThat(res.as(String.class), is(DATA+DATA+DATA));
IllegalStateException ex = assertThrows(IllegalStateException.class, res::trailers);
assertThat(ex.getMessage(), is("No trailers are expected."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void router(HttpRouting.Builder router) {
String joinedHeaders = req.headers()
.stream()
.filter(h -> h.name().startsWith("test-header-"))
.map(h -> h.name() + "=" + h.value())
.map(h -> h.name() + "=" + h.get())
.collect(Collectors.joining("\n"));
res.send(joinedHeaders);
}
Expand Down

0 comments on commit ddf6976

Please sign in to comment.