Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion okhttp/src/jvmTest/kotlin/okhttp3/DuplexTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,27 @@ class DuplexTest {
fun duplexWithAuthChallenge() {
enableProtocol(Protocol.HTTP_2)
val credential = basic("jesse", "secret")
val duplexResponseSent = CountDownLatch(1)
val requestHeadersEndListener =
object : EventListener() {
override fun requestHeadersEnd(
call: Call,
request: Request,
) {
// Wait for the server to send the duplex response before acting on the 401 response
// and resetting the stream.
duplexResponseSent.await()
}
}
client =
client
.newBuilder()
.authenticator(RecordingOkAuthenticator(credential, null))
.eventListener(eventRecorder.eventListener + requestHeadersEndListener)
.build()
val body1 =
MockSocketHandler()
.sendResponse("please authenticate!\n")
.sendResponse("please authenticate!\n", duplexResponseSent)
.requestIOException()
.exhaustResponse()
server.enqueue(
Expand Down