-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x] Add test for 103 handling #8055
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1026,6 +1026,13 @@ class MockWebServer : ExternalResource(), Closeable { | |
readBody = true | ||
} | ||
|
||
peek.informationalResponses.forEach { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, I dislike |
||
val informationalHeader = | ||
listOf(Header(Header.RESPONSE_STATUS, it.status.replace("HTTP/1.1 ", ""))) | ||
stream.writeHeaders(informationalHeader, outFinished = false, flushHeaders = true) | ||
stream.connection.flush() | ||
} | ||
|
||
val body = Buffer() | ||
val requestLine = "$method $path HTTP/1.1" | ||
var exception: IOException? = null | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2812,6 +2812,43 @@ public void cancelWhileRequestHeadersAreSent_HTTP_2() throws Exception { | |
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("abc"); | ||
} | ||
|
||
@Test | ||
public void serverRespondsWithEarlyHintsHttp2() throws Exception { | ||
enableProtocol(Protocol.HTTP_2); | ||
server.enqueue( | ||
new MockResponse() | ||
.addInformationalResponseInternal( | ||
new MockResponse().setResponseCode(103).addHeader("Link", "</style.css>; rel=preload; as=style") | ||
) | ||
); | ||
Request request = new Request.Builder() | ||
.url(server.url("/")) | ||
.post(RequestBody.create("abc", MediaType.get("text/plain"))) | ||
.build(); | ||
executeSynchronously(request) | ||
.assertFailure(SocketTimeoutException.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Showing we don't handle this well. cc @swankjesse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
} | ||
|
||
@Test | ||
public void serverRespondsWithEarlyHintsHttp1() throws Exception { | ||
server.enqueue( | ||
new MockResponse() | ||
.addInformationalResponseInternal( | ||
new MockResponse().setResponseCode(103).addHeader("Link", "</style.css>; rel=preload; as=style") | ||
) | ||
); | ||
Request request = new Request.Builder() | ||
.url(server.url("/")) | ||
.post(RequestBody.create("abc", MediaType.get("text/plain"))) | ||
.build(); | ||
executeSynchronously(request) | ||
.assertSuccessful() | ||
.assertCode(200); | ||
RecordedRequest recordedRequest = server.takeRequest(); | ||
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("abc"); | ||
assertThat(recordedRequest.getHeader("Link")).isNull(); | ||
} | ||
|
||
@Test public void serverRespondsWithUnsolicited100Continue_HTTP2() throws Exception { | ||
enableProtocol(Protocol.HTTP_2); | ||
serverRespondsWithUnsolicited100Continue(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not great, but seems better to have some limited support without the bigger change of backporting.
cc @swankjesse