req icon indicating copy to clipboard operation
req copied to clipboard

关于 SetHeadersNonCanonical(协议头大小写敏感) 在 https 中失效

Open 0xObjc opened this issue 7 months ago • 2 comments

func TestHttps(t *testing.T) {
	c := req.C().EnableDumpAll().SetBaseURL("https://httpbin.org")
	r := c.R()
	r.SetHeadersNonCanonical(map[string]string{
		"USID": "123", // 用户 ID
	})
	r.SetHeaderNonCanonical("CTERMINAL", "ui")
	res, _ := r.Post("/post")
	t.Log(res.String())
}

/*
:authority: httpbin.org
:method: POST
:path: /post
:scheme: https
usid: 123
cterminal: ios
content-length: 0
accept-encoding: gzip
user-agent: req/v3 (https://github.com/imroc/req)

*/

func TestHttp(t *testing.T) {
	c := req.C().EnableDumpAll().SetBaseURL("http://httpbin.org")
	r := c.R()
	r.SetHeadersNonCanonical(map[string]string{
		"USID": "123", // 用户 ID
	})
	r.SetHeaderNonCanonical("CTERMINAL", "ui")
	res, _ := r.Post("/post")
	t.Log(res.String())
}

/*
POST /post HTTP/1.1
Host: httpbin.org
User-Agent: req/v3 (https://github.com/imroc/req)
Content-Length: 0
CTERMINAL: ui
USID: 123
Accept-Encoding: gzip
*/

0xObjc avatar Jul 21 '24 04:07 0xObjc