-
Notifications
You must be signed in to change notification settings - Fork 18k
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
x/net/http2: make net/http/httputil/ DumpRequestOut working on http2 ?? #18464
Comments
the actual need behind this is I want some application level debugging for http2, from https://golang.org/pkg/net/http/httptrace/ it's good to have a from the https://golang.org/src/net/http/h2_bundle.go #L5496 5496 hdrs, err := cc.encodeHeaders(req, requestedGzip, trailers, contentLen) https://github.com/golang/net/blob/master/http2/transport.go#L754-L772 // we send: HEADERS{1}, CONTINUATION{0,} + DATA{0,} (DATA is
// sent by writeRequestBody below, along with any Trailers,
// again in form HEADERS{1}, CONTINUATION{0,})
hdrs, err := cc.encodeHeaders(req, requestedGzip, trailers, contentLen)
if err != nil {
cc.mu.Unlock()
return nil, err
}
cs := cc.newStream()
cs.req = req
cs.trace = requestTrace(req)
cs.requestedGzip = requestedGzip
bodyWriter := cc.t.getBodyWriterState(cs, body)
cs.on100 = bodyWriter.on100
cc.wmu.Lock()
endStream := !hasBody && !hasTrailers
werr := cc.writeHeaders(cs.ID, endStream, hdrs) |
For questions about Go, see https://golang.org/wiki/Questions. As the docs say:
Dumping in binary would be unreadable and useless. If you want to see how the sausage is made, see https://godoc.org/golang.org/x/net/http2. |
why is this closed so early? @bradfitz I didn't ask to dump the binary, but a better text format more close to what's seen in Chrome DevTool: like :authority: http2bin.org
:method: GET
:path: /get
:scheme: https
accept-encoding: gzip
user-agent: ...
[request body]
:status: 200
server: h2o/2.0.4
date: ...
content-type: ...
[response body] |
this is not only a question, but something deserve to be improved in code of course I have read that; but the problem I pointed out is the current http2 code didn't give application level an inspect interface to know what headers are written into the wire; this is a feature request |
The Chrome text format is almost as arbitrary as any http2-binary-to-text format, including Go's format, which is at least consistent with Go's http1 format. If you want a certain format, you're free to implement one. I don't think more formats are a good idea for the standard library. It's too little value for too much overlap. I'd prefer this be implemented outside the Go libraries as an opt-in mechanism people can use when they want to match Chrome. We already provide GODEBUG=http2debug=2 when you want to see exactly what's happening. |
the https://github.com/golang/net/blob/master/http2/http2.go#L42-L52 I have found the
https://golang.org/pkg/net/http/httptrace/ // WroteHeaders is called after the Transport has written
// the request headers.
WroteHeaders func()
// WroteRequest is called with the result of writing the
// request and any body.
WroteRequest func(WroteRequestInfo) |
if Let me point you some different API design in different pro language / libraries: @bradfitz
Current Golang http2 code doesn't have any of these features; I have read the doc and most of the Go code under net/http2 |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.7.4
What operating system and processor architecture are you using (
go env
)?Linux amd64
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
A simple http2 client program, make get request to https://http2bin.org/get
use DumpResponse / DumpRequestOut (from net/http/httputil/) to print the Request & Response,
What did you expect to see?
http2 headers for request & response should be different with http1, should be all lower cases, in Chrome DevTool like other command line tools it's commonly shown as:
What did you see instead?
========
BTW, set
GODEBUG=http2debug=2
get following debugging logs:The text was updated successfully, but these errors were encountered: