http3: set the Content-Length header in the http.Request.Header map (#3963)

This commit is contained in:
Marten Seemann 2023-07-16 19:26:15 -07:00 committed by GitHub
parent 3dea8f8a9b
commit 8ac22a9483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -83,10 +83,12 @@ func requestFromHeaders(headers []qpack.HeaderField) (*http.Request, error) {
var contentLength int64
if len(contentLengthStr) > 0 {
contentLength, err = strconv.ParseInt(contentLengthStr, 10, 64)
cl, err := strconv.ParseInt(contentLengthStr, 10, 64)
if err != nil {
return nil, err
}
httpHeaders.Set("Content-Length", contentLengthStr)
contentLength = cl
}
return &http.Request{

View file

@ -26,7 +26,8 @@ var _ = Describe("Request", func() {
Expect(req.ProtoMajor).To(Equal(3))
Expect(req.ProtoMinor).To(BeZero())
Expect(req.ContentLength).To(Equal(int64(42)))
Expect(req.Header).To(BeEmpty())
Expect(req.Header).To(HaveLen(1))
Expect(req.Header.Get("Content-Length")).To(Equal("42"))
Expect(req.Body).To(BeNil())
Expect(req.Host).To(Equal("quic.clemente.io"))
Expect(req.RequestURI).To(Equal("/foo"))