Skip to content

proposal: add a Size field to http.Request #19644

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

Closed
joshi4 opened this issue Mar 21, 2017 · 1 comment
Closed

proposal: add a Size field to http.Request #19644

joshi4 opened this issue Mar 21, 2017 · 1 comment

Comments

@joshi4
Copy link

joshi4 commented Mar 21, 2017

I'm trying to add a metric that measures the total size of the request in bytes on the wire as received by the server(headers + body + trailer). This does not seem possible at the moment.

I propose we add a Size field to http.Request that behaves similar to the Trailer field.

type Request struct {
  // Size is the total bytes of the Request including headers, body and
  // trailers. 
  // 
  // For server requests Size is initially zero. While the handler is 
  // reading from Body, it must not reference Size. After reading from Body 
  // returns EOF, Size can be read and will contain the total bytes of the
  // Request including headers, body and trailers. 
  //
  // For client requests Size is always set to zero. 
  Size int64 
}
@gopherbot gopherbot added this to the Proposal milestone Mar 21, 2017
@bradfitz
Copy link
Contributor

Sorry, I'm going to decline this.

I've had to deal with implementing this for logging several times. Everybody means something different in how exactly you calculate this and anything we add is going to be insufficient for somebody else. Do you count http2 frame sizes? Or only the payload size? Before or after compression? Before or after whitespace normalization? Before or after header folding? etc.

If anything, this can be addressed in the httptrace package. Currently httptrace only has ClientTrace, but in #18997 people are discussing ServerTrace hooks. That's the right place for low-level disgusting detail where we don't care about godoc pollution. And we could add numbers and hooks for all the possible things you might care about.

@golang golang locked and limited conversation to collaborators Mar 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants