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: using DumpResponse without requests #29658

Closed
schmilmo opened this issue Jan 10, 2019 · 5 comments
Closed

net/http: using DumpResponse without requests #29658

schmilmo opened this issue Jan 10, 2019 · 5 comments

Comments

@schmilmo
Copy link

Hi,

I'm trying to build a HTTP sniffer.
I used http.ReadResponse as following

res, err := http.ReadResponse(b, nil)
if err == io.EOF || err == io.ErrUnexpectedEOF {
	break
} else if err != nil {
	fmt.printf("HTTP Response error: %s \n", err)
	continue
}
body, err := ioutil.ReadAll(res.Body)

but some parts of the response are missing such as the delimiters
I would like to dump the raw response, is it possible to use httputil.DumpResponse?

Samuel

@ALTree ALTree changed the title Using DumpResponse without requests net/http: using DumpResponse without requests Jan 10, 2019
@bradfitz
Copy link
Contributor

Nope, those aren't preserved. You'll need to do something lower-level with the net package directly if you need that.

@schmilmo
Copy link
Author

So is there anyway to get the HTTP message total length when using ReadResponse?

@bradfitz
Copy link
Contributor

There are various definitions for "total length". Which do you mean?

@schmilmo
Copy link
Author

Sum of all TCP payloads that represent the current HTTP message

@bradfitz
Copy link
Contributor

Nope, sorry. That isn't tracked. You might be able to recreate a close value, but optional whitespace and such is discarded.

@golang golang locked and limited conversation to collaborators Jan 14, 2020
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

4 participants