-
Notifications
You must be signed in to change notification settings - Fork 114
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
有获取cookie的接口吗 #257
Comments
是要自动管理服务端生成的cookie? |
如果是,可以看下下面的代码 jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
if err != nil {
log.Fatal(err)
}
client := &http.Client{
Jar: jar,
}
gout.New(client).GET(ts.URL).SetBody("hi cookie").Do()
gout.New(client).GET(ts.URL).SetBody("hi cookie2").Do() //抓下包就可以看到自动持有服务端一开始设置的cookie了。 |
但是我需要保存服务端设置的cookie到本地,以供别的程序做模拟登录用 |
可以通过BindHeader获取cookie的值。 type rspHeader struct {
SetCookie string `header:"Set-Cookie"`
}
var header rspHeader
gout.New().GET(ts.URL).SetBody("hi cookie").BindHeader(&header).Do()
fmt.Printf("cookie value:%v\n", header) |
好的,感谢 |
ok |
如何用网页端的raw版cookie直接设置到请求中? 同样也是模拟登录, |
类似这种cookie
|
抱歉懂了, 从python转过来突然有点不适应, 如果不懂朋友, 可以直接把rawcookie直接设置到headers上即可. 浏览器 cookie |
@bequt 欢迎进入go的世界. 有时间也可以一起完善gout的文档. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如题,有获取cookie的接口吗
The text was updated successfully, but these errors were encountered: