grequests icon indicating copy to clipboard operation
grequests copied to clipboard

http请求头重复 bug HTTP request header duplicates bugs

Open wivd opened this issue 6 years ago • 1 comments

opt  := &grequests.RequestOptions{}
	proxyURL, err := url.Parse("http://127.0.0.1:8080")
	//body := strings.NewReader("username=admin&password=password&Login=Login")

	opt.Headers = map[string]string{
		"test":"test",
	}

	opt.Proxies = map[string]*url.URL{proxyURL.Scheme: proxyURL}

	//opt.RequestBody = body
	opt.UseCookieJar = true
	opt.DisableCompression = false
	opt.Data =  map[string]string{"username":"admin","password":"password","Login":"Login"}

	resp,err := grequests.Post ("http://192.168.95.4/aaa/login.php",opt)
	fmt.Println(err)
	//fmt.Println(resp.String())
	fmt.Println(resp.StatusCode)

After login, the corresponding 302 status code of the web server,When grequests continues to make requests, the “test” header in the HTTP request header repeats http requests

GET /aaa/index.php HTTP/1.1
Host: 192.168.95.4
User-Agent: GRequests/0.10
Content-Type: application/x-www-form-urlencoded
Content-Type: application/x-www-form-urlencoded
Cookie: security=high; PHPSESSID=90949a1f57fa20a9e948f589e17a6786
Referer: http://192.168.95.4/aaa/login.php
Test: test
Test: test
Accept-Encoding: gzip, deflate
Connection: close

The reason is that the function "addRedirectFunctionality" in the utils. go file uses req. Header. Add (k, v) , Modified to req. Header.Set (k, v) resolves the problem of duplication of HTTP request headers

My English is very poor

wivd avatar Jun 29 '19 05:06 wivd

https://github.com/lib4u/grequest new project

lib4u avatar Jan 07 '25 11:01 lib4u