<p>http.Response.Cookies() is returning an empty list, but the Response carries a 'Set-Cookies' header with valid data. Also, the CookieJar isn't catching any cookies either:</p>
<pre><code>fmt.Println("Set-Cookie:", strings.Join(rsp.Header["Set-Cookie"], " | "))
fmt.Println("Cookies(): ", rsp.Cookies())
fmt.Println("Jar: ", jar)
</code></pre>
<p>Output:</p>
<pre><code>Set-Cookie: express:sess=eyJwYXNzcG9ydCI6e30sImZsYXNoIjp7fX0=; path=/; httponly | express:sess.sig=QSHjYGweA7mxUoPNgmgRcJxY8Ws; path=/; httponly
Cookies(): []
Jar: &{<nil> {0 0} map[] 0}
</code></pre>
<p>I'm sure I'm doing something wrong, I just can't spot the problem. Thoughts?</p>
<p>EDIT: It appears that Go's HTTP stack doesn't consider ExpressJS cookie names to be valid, but it's not clear to me why not. I pulled out the relevant bits of the HTTP cookie parsing stack to produce this demo, but I still don't understand why these cookie names aren't considered to be valid:</p>
<p><a href="https://play.golang.org/p/13g728UPkF" rel="nofollow">https://play.golang.org/p/13g728UPkF</a></p>
<hr/>**评论:**<br/><br/>barsonme: <pre><p><code>:</code> is not valid inside a cookie name. It is a separator. You can read about it in the RFC: <a href="https://tools.ietf.org/html/rfc2616#section-2.2" rel="nofollow">https://tools.ietf.org/html/rfc2616#section-2.2</a></p></pre>weberc2: <pre><p>That answers my question. Thanks!</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传