-
-
Notifications
You must be signed in to change notification settings - Fork 37
encode error #21
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
Comments
@prettyyjnic Thanks for your report. But I can't reproduce it. My test code: test.go package main
import (
"fmt"
"io/ioutil"
"net/http"
"reflect"
"github.com/mozillazg/request"
)
func test1(url string) (bt []byte, err error) {
testResp, err := http.Get(url)
if err != nil {
return
}
bt, err = ioutil.ReadAll(testResp.Body)
return
}
func test2(url string) (bt []byte, err error) {
c := new(http.Client)
req := request.NewRequest(c)
resp, err := req.Get(url)
if err != nil {
return
}
bt, err = ioutil.ReadAll(resp.Body)
return
}
func main() {
url := "https://httpbin.org/status/418"
b1, _ := test1(url)
b2, _ := test2(url)
fmt.Println(b1)
fmt.Println(b2)
fmt.Println(reflect.DeepEqual(b1, b2))
} result
What is the "uncorrect string" ? Can you post it here? |
@mozillazg I found the reason . If the website compress with the gzip , i would got the uncorrect return. When i decode it by myself, i got the correct return
the result is :
|
@prettyyjnic I got it. This is because the default https://github.com/mozillazg/request/blob/master/headers.go#L6
It works as expected. You can change |
@mozillazg ok, thanks |
@prettyyjnic You're welcome. |
if i use your library i got the uncorrect encode return , but i got the correct return while i use the http library
The text was updated successfully, but these errors were encountered: