From 32f8b20ae5fdfa6d508d00a232b2543240cc6ca0 Mon Sep 17 00:00:00 2001
From: roc <roc@imroc.cc>
Date: Sat, 29 Jul 2023 12:18:26 +0800
Subject: [PATCH] http3: fix check for content length of the response (#3998)

* fix: check response content-length other than request content-length

* Update http3/client.go

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
---
 http3/client.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/http3/client.go b/http3/client.go
index d53391f0..cc2400e2 100644
--- a/http3/client.go
+++ b/http3/client.go
@@ -429,8 +429,8 @@ func (c *client) doRequest(req *http.Request, conn quic.EarlyConnection, str qui
 	// Check that the server doesn't send more data in DATA frames than indicated by the Content-Length header (if set).
 	// See section 4.1.2 of RFC 9114.
 	var httpStr Stream
-	if _, ok := req.Header["Content-Length"]; ok && req.ContentLength >= 0 {
-		httpStr = newLengthLimitedStream(hstr, req.ContentLength)
+	if _, ok := res.Header["Content-Length"]; ok && res.ContentLength >= 0 {
+		httpStr = newLengthLimitedStream(hstr, res.ContentLength)
 	} else {
 		httpStr = hstr
 	}