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

Read gzipped response and request marshal include headers #171

Merged
merged 4 commits into from
Jun 27, 2018

Conversation

mumugoah
Copy link
Contributor

@mumugoah mumugoah commented Jun 21, 2018

  1. add feather: read gzipped HTTP response
  2. fix: request marshal and unMarshal include headers (fix should request marshal include headers? #169 )

@mumugoah mumugoah changed the title read gzipped response and request marshal include headers Read gzipped response and request marshal include headers Jun 21, 2018
Copy link
Member

@asciimoo asciimoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good PR, thanks! Please check the review notes.

request.go Outdated
@@ -56,6 +56,7 @@ type serializableRequest struct {
Body []byte
ID uint32
Ctx map[string]interface{}
Header http.Header
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call it Headers to be compatible with the current naming convention.

http_backend.go Outdated
@@ -185,6 +187,12 @@ func (h *httpBackend) Do(request *http.Request, bodySize int) (*Response, error)
if bodySize > 0 {
bodyReader = io.LimitReader(bodyReader, int64(bodySize))
}
if res.Header.Get("Content-Encoding") == "gzip" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I know golang's http lib handles compression by default. If it successfully decompresses the content, then res.Uncompressed [1] is true, so we could check here if decompression happened to avoid double decompression:

if !res.Uncompressed && res.Header.Get("Content-Encoding") == "gzip" {

[1] https://golang.org/pkg/net/http/#Response

@mumugoah
Copy link
Contributor Author

@asciimoo ok, I'll correct it

Copy link
Member

@asciimoo asciimoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@asciimoo asciimoo merged commit 2e03a39 into gocolly:master Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

should request marshal include headers?
2 participants