Skip to content

Conversation

@one-kash
Copy link

Summary

Improve the error message when response headers exceed the 256 KiB limit.

Before:

java.io.EOFException: \n not found: limit=0 content=…

After:

java.net.ProtocolException: Header line limit exceeded (256 KiB). The response headers are too large.

Changes

  • Catch EOFException from readUtf8LineStrict in HeadersReader.readLine()
  • Throw a ProtocolException with a descriptive message that clearly states the cause
  • Chain the original exception as the cause for debugging

Test Plan

  • Verified compilation succeeds
  • The change improves error messaging without changing behavior

Fixes #9233

When response headers exceed the 256 KiB limit, the error message was
a generic "\\n not found: limit=0" from Okio's readUtf8LineStrict.

Now the error message clearly states:
"Header line limit exceeded (256 KiB). The response headers are too large."

This helps users immediately understand the cause without having to
dig into OkHttp internals.

Fixes square#9233
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.

Better error messages when headers length exceed their limits

1 participant