From 21697a2503417bf78c204499fa6509f01b51073a Mon Sep 17 00:00:00 2001 From: roc Date: Tue, 26 Sep 2023 10:13:57 +0800 Subject: [PATCH] Ignore PseudoHeaderOderKey while write http/1.1 header --- header.go | 6 ++++-- http_request.go | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/header.go b/header.go index d31da8d7..3c94f7db 100644 --- a/header.go +++ b/header.go @@ -1,14 +1,16 @@ package req import ( - "github.com/imroc/req/v3/internal/header" - "golang.org/x/net/http/httpguts" "io" "net/http" "net/textproto" "sort" "strings" "sync" + + "golang.org/x/net/http/httpguts" + + "github.com/imroc/req/v3/internal/header" ) var headerNewlineToSpace = strings.NewReplacer("\n", " ", "\r", " ") diff --git a/http_request.go b/http_request.go index c737a6b3..5816de44 100644 --- a/http_request.go +++ b/http_request.go @@ -2,11 +2,13 @@ package req import ( "errors" - "github.com/imroc/req/v3/internal/ascii" - "github.com/imroc/req/v3/internal/header" - "golang.org/x/net/http/httpguts" "net/http" "strings" + + "golang.org/x/net/http/httpguts" + + "github.com/imroc/req/v3/internal/ascii" + "github.com/imroc/req/v3/internal/header" ) // Given a string of the form "host", "host:port", or "[ipv6::address]:port", @@ -88,12 +90,13 @@ func closeRequestBody(r *http.Request) error { // Headers that Request.Write handles itself and should be skipped. var reqWriteExcludeHeader = map[string]bool{ - "Host": true, // not in Header map anyway - "User-Agent": true, - "Content-Length": true, - "Transfer-Encoding": true, - "Trailer": true, - header.HeaderOderKey: true, + "Host": true, // not in Header map anyway + "User-Agent": true, + "Content-Length": true, + "Transfer-Encoding": true, + "Trailer": true, + header.HeaderOderKey: true, + header.PseudoHeaderOderKey: true, } // requestMethodUsuallyLacksBody reports whether the given request