Skip to content

Commit

Permalink
Expand 103 handling to other non-specific 1XX messages. (square#7629)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7e4576c)
  • Loading branch information
yschimke committed Jan 5, 2023
1 parent 2aa40be commit b636618
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ class CallServerInterceptor(private val forWebSocket: Boolean) : Interceptor {
// actual response status.
code == 100 -> true

// Early Hints (103) but not supported yet in OkHttp
code == 103 -> true
// Handle Processing (102) & Early Hints (103) and any new codes without failing
// 100 and 101 are the exceptions with different meanings
// But Early Hints not currently exposed
code in (102 until 200) -> true

else -> false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import okhttp3.internal.http.StatusLine
import okhttp3.internal.http.promisesBody
import okhttp3.internal.http.receiveHeaders
import okhttp3.internal.http.HTTP_CONTINUE
import okhttp3.internal.http.HTTP_EARLY_HINTS
import okhttp3.internal.skipAll
import okio.Buffer
import okio.BufferedSink
Expand Down Expand Up @@ -192,8 +193,9 @@ class Http1ExchangeCodec(
state = STATE_READ_RESPONSE_HEADERS
responseBuilder
}
statusLine.code == HTTP_EARLY_HINTS -> {
// Early Hints will mean a second header are coming.
statusLine.code in (102 until 200) -> {
// Processing and Early Hints will mean a second headers are coming.
// Treat others the same for now
state = STATE_READ_RESPONSE_HEADERS
responseBuilder
}
Expand Down

0 comments on commit b636618

Please sign in to comment.