-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
http3: fix check for content length of the response #3998
Conversation
What are you trying to achieve with this change? |
Just like the logic written in comments: |
A simple example to reproduce the bug: package main
import (
"github.com/quic-go/quic-go/http3"
"io"
"net/http"
"strings"
)
func main() {
client := &http.Client{
Transport: &http3.RoundTripper{},
}
req, err := http.NewRequest(http.MethodPost, "https://www.cloudflare.com/", strings.NewReader("test"))
if err != nil {
panic(err)
}
req.Header.Set("Content-Length", "4")
res, err := client.Do(req)
if err != nil {
panic(err)
}
_, err = io.ReadAll(res.Body)
if err != nil {
panic(err)
}
} Run the code: $ go run .
panic: peer sent too much data
goroutine 1 [running]:
main.main()
/Users/roc/dev/test/quic-go/main.go:25 +0x2d4
exit status 2 |
Current logic: Check if response body content-length if greater than Should change to: Check if response body content-length if greater than |
Oh, I see! I missed that you're using |
OK, |
Codecov Report
@@ Coverage Diff @@
## master #3998 +/- ##
==========================================
- Coverage 82.86% 82.82% -0.04%
==========================================
Files 146 146
Lines 14729 14729
==========================================
- Hits 12204 12198 -6
- Misses 2025 2030 +5
- Partials 500 501 +1
|
No description provided.