Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wivd opened this issue Jun 29, 2019 · 0 comments
Open

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

wivd opened this issue Jun 29, 2019 · 0 comments

Comments

@wivd
Copy link

wivd commented Jun 29, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant