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

[BUG] http: ContentLength=xx with Body length 0 #48

Closed
ioito opened this issue Aug 31, 2021 · 1 comment
Closed

[BUG] http: ContentLength=xx with Body length 0 #48

ioito opened this issue Aug 31, 2021 · 1 comment
Labels

Comments

@ioito
Copy link

ioito commented Aug 31, 2021

Describe the bug
A clear and concise description of what the bug is.

after #31 merged

client.Do(req) https request will return http: ContentLength=xx with Body length 0 error after http2curl.GetCurlCommand(req) called

To Reproduce

str := `{"hello":"world"}`
req, _ := http.NewRequest("POST", `https://www.baidu.com`, strings.NewReader(str))
req.Header.Set("Content-Length", strconv.FormatInt(int64(len(str)), 10))
client := &http.Client{
    Transport: &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    },
}
http2curl.GetCurlCommand(req)
_, err := client.Do(req)
if err != nil {
    fmt.Println("err: ", err)
}

/cc @Dzalevski

@djale1k
Copy link
Contributor

djale1k commented Aug 31, 2021

@ioito @moul Yes. GetCurlCmd after reading from the body will be empty it :) -> it was made for a performance boost.
maybe you can make a duplicate buff for req.

@moul moul closed this as completed Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants