-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.x] Backport 1XX handling from master (#7634)
* Ignore early hints for 4.9.x (#7444) (cherry picked from commit b565eec) * Expand 103 handling to other non-specific 1XX messages. (#7629) (cherry picked from commit 7e4576c) * Cleanup * Add a test of 103 handling * Add copyright * Add copyright * Fix cache test for 102/103 (#7633) (cherry picked from commit 930f138) * Disable test
- Loading branch information
Showing
5 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
okhttp/src/test/java/okhttp3/InformationalResponseCodeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2023 Block, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package okhttp3 | ||
|
||
import okhttp3.testing.PlatformRule | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Ignore | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
@Ignore("For manual testing only") | ||
class InformationalResponseCodeTest { | ||
@JvmField @Rule | ||
val platform = PlatformRule() | ||
|
||
@JvmField @Rule val clientTestRule = OkHttpClientTestRule().apply { | ||
recordFrames = true | ||
} | ||
|
||
private var client = clientTestRule.newClient() | ||
|
||
@Test | ||
fun test103() { | ||
// Pretend we are curl so cloudflare will send a 103 | ||
val request = Request.Builder() | ||
.url("https://tradingstrategy.ai") | ||
.header("user-agent", "curl/7.85.0") | ||
.build() | ||
|
||
val response = client.newCall(request).execute() | ||
|
||
assertThat(response.code).isEqualTo(200) | ||
assertThat(response.protocol).isEqualTo(Protocol.HTTP_2) | ||
response.close() | ||
|
||
val outgoingHeaders = ">> 0x00000003\\s+\\d+\\s+HEADERS\\s+END_STREAM\\|END_HEADERS".toRegex() | ||
assertThat(clientTestRule.eventsList().filter { it.matches(outgoingHeaders) }).hasSize(1) | ||
|
||
// Confirm we get the informational response and final response headers. | ||
val incomingHeaders = "<< 0x00000003\\s+\\d+\\s+HEADERS\\s+END_HEADERS".toRegex() | ||
assertThat(clientTestRule.eventsList().filter { it.matches(incomingHeaders) }).hasSize(2) | ||
} | ||
} |