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/httputil: DumpRequest and ReadRequest are incompatible #9144

Closed
gopherbot opened this issue Nov 21, 2014 · 3 comments
Closed

net/http/httputil: DumpRequest and ReadRequest are incompatible #9144

gopherbot opened this issue Nov 21, 2014 · 3 comments
Milestone

Comments

@gopherbot
Copy link

by timothe@google.com:

Tested under go version 1.3 and 1.4RC

Cf. https://play.golang.org/p/tYAkpOSAOs

When you call http.ReadRequest on a raw request string that was dumped using DumpRequest
(or DumpRequestOut) the resulting request.URL is not filled, thus making it impossible
to issue via a Transport. (It will fail complaining about an 'unsupported protocol
scheme ""' because the URL doesn't start with any protocol indeed (cf
playground example)

Unrelated error but other people are also seeing a need for correct behavior of
ReadRequest
(https://golang.org/issue/7215&;q=httputil&colspec=ID%20Status%20Stars%20Release%20Owner%20Repo%20Summary)
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.5.

@bradfitz
Copy link
Contributor

Comment 2:

These aren't expected to round-trip. Information is naturally lost here because the wire
format doesn't include information about e.g. which scheme was used. ReadRequest never
populates the URL scheme.
These dump functions are mostly for debugging.
If you're writing a proxy, there is httputil.ReverseProxy to help.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 3 by timothe@google.com:

Thanks for the quick reply.
Actually it does populates the URL scheme, but only for very specific cases (I just had
a look at http://golang.org/src/pkg/net/http/readrequest_test.go).
it's a shame we don't have a way to parse requests and issue them again, I am indeed
writing a proxy but needs to be able to reissue prior requests slightly modified (doing
security tests around various request parameters, could be host, url params, path, etc.).
I'll have a look at the httputil.ReverseProxy if it can help me do this.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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