Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: ErrContentLength not returned for too-long HTTP/2 body writes #56019

Open
neild opened this issue Oct 4, 2022 · 3 comments
Open

net/http: ErrContentLength not returned for too-long HTTP/2 body writes #56019

neild opened this issue Oct 4, 2022 · 3 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@neild
Copy link
Contributor

neild commented Oct 4, 2022

// ErrContentLength is returned by ResponseWriter.Write calls
// when a Handler set a Content-Length response header with a
// declared size and then attempted to write more bytes than
// declared.
ErrContentLength = errors.New("http: wrote more than the declared Content-Length")

Writing too many bytes to an HTTP/2 body doesn't return ErrContentLength, however, for two reasons:

  1. The HTTP/2 ResponseWriter returns a different error when detecting a too-long body.
  2. The accounting for how many bytes have been written can fail to detect a too-long body until after the ResponseWriter.Write call has returned.

The existing test TestIdentityResponse fails when run in HTTP/2 mode.

@neild neild added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 4, 2022
@neild neild added this to the Backlog milestone Oct 4, 2022
@nikola-jokic
Copy link

nikola-jokic commented Nov 9, 2022

Hey @neild, can I give it a try? ☺️

@neild
Copy link
Contributor Author

neild commented Nov 10, 2022

Hey @neild, can I give it a try? ☺️

Please do! I'm happy to review a CL.

@gopherbot
Copy link

gopherbot commented Nov 14, 2022

Change https://go.dev/cl/450255 mentions this issue: net/http: ResponseWriter checks for the Content-Length before writing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants