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

add global options #41

Closed
wants to merge 3 commits into from
Closed

add global options #41

wants to merge 3 commits into from

Conversation

zwczou
Copy link
Contributor

@zwczou zwczou commented Nov 1, 2016

package main

import (
	"log"
	"net/http/httputil"

	"github.com/levigross/grequests"
)

func main() {
	sess := grequests.NewSession(&grequests.RequestOptions{
		Headers: map[string]string{
			"Accept":          "*/*",
		},
		UserAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36",
	})
	sess = grequests.NewSession(nil)

	resp, err := sess.Get("http://baidu.com", nil)
	if err != nil {
		log.Fatal(err)
	}
	body, err := httputil.DumpRequest(resp.RawResponse.Request, true)
	if err != nil {
		log.Fatal(err)
	}
	println(string(body))
}

@zwczou zwczou closed this Nov 1, 2016
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

Successfully merging this pull request may close these issues.

2 participants