Skip to content

KTOR-9937 OkHttp: Do not read the body of responses without a body - #5904

Open
Ruslan Ibrahimau (IRus) wants to merge 1 commit into
ktorio:mainfrom
IRus:fix/okhttp-no-body
Open

Ruslan Ibrahimau (IRus) wants to merge 1 commit into
ktorio:mainfrom
IRus:fix/okhttp-no-body

Conversation

@IRus

Copy link
Copy Markdown
Contributor

OkHttp expects a body for a 304 response when Content-Length is present, so copying ResponseBody into the response channel waited for bytes that never come and hung on a keep-alive connection. Responses to HEAD, and 1xx, 204 and 304 responses, end at the header section (RFC 9112 §6.3), as in the CIO engine.

Subsystem
Client, OkHttp engine

Motivation
https://youtrack.jetbrains.com/issue/KTOR-9937/OkHttp-reading-a-304-response-that-carries-Content-Length-hangs-until-timeout

Solution
Skip reading the OkHttp response body for HEAD, 1xx, 204 and 304 responses

OkHttp expects a body for a 304 response when Content-Length is present, so
copying ResponseBody into the response channel waited for bytes that never
come and hung on a keep-alive connection. Responses to HEAD, and 1xx, 204 and
304 responses, end at the header section (RFC 9112 §6.3), as in the CIO
engine.
@IRus Ruslan Ibrahimau (IRus) changed the title KTOR-9937: OkHttp: Do not read the body of responses without a body KTOR-9937 OkHttp: Do not read the body of responses without a body Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant