HELP: http.Response.Cookies() is returning empty list

blov · · 371 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>http.Response.Cookies() is returning an empty list, but the Response carries a &#39;Set-Cookies&#39; header with valid data. Also, the CookieJar isn&#39;t catching any cookies either:</p> <pre><code>fmt.Println(&#34;Set-Cookie:&#34;, strings.Join(rsp.Header[&#34;Set-Cookie&#34;], &#34; | &#34;)) fmt.Println(&#34;Cookies(): &#34;, rsp.Cookies()) fmt.Println(&#34;Jar: &#34;, jar) </code></pre> <p>Output:</p> <pre><code>Set-Cookie: express:sess=eyJwYXNzcG9ydCI6e30sImZsYXNoIjp7fX0=; path=/; httponly | express:sess.sig=QSHjYGweA7mxUoPNgmgRcJxY8Ws; path=/; httponly Cookies(): [] Jar: &amp;{&lt;nil&gt; {0 0} map[] 0} </code></pre> <p>I&#39;m sure I&#39;m doing something wrong, I just can&#39;t spot the problem. Thoughts?</p> <p>EDIT: It appears that Go&#39;s HTTP stack doesn&#39;t consider ExpressJS cookie names to be valid, but it&#39;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&#39;t understand why these cookie names aren&#39;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

371 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传