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

@schmilmo schmilmo commented Jan 10, 2019

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
@ALTree ALTree added the Question label Jan 10, 2019
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Jan 10, 2019

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

@bradfitz bradfitz closed this Jan 10, 2019
@schmilmo

This comment has been minimized.

Copy link
Author

@schmilmo schmilmo commented Jan 11, 2019

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

@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Jan 11, 2019

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

@schmilmo

This comment has been minimized.

Copy link
Author

@schmilmo schmilmo commented Jan 13, 2019

Sum of all TCP payloads that represent the current HTTP message

@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Jan 14, 2019

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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.