<p>I want to download the Java dmg for my OS X platform using GO.
<a href="https://play.golang.org/p/9XKjsSVZN4" rel="nofollow">Here</a> is my code. The cookie is needed because (as a user) you need to accept a license. I knew that home-brew (a package manager for OS X) is capable of downloading Java. So it checked the file and saw that a cookie is needed. I tried to get it working somehow but I always get 5307 as file size, which is clearly wrong. The actual file size is a bit over 60 MB. </p>
<p>Any help is appreciated. I am still quite new to GO.</p>
<hr/>**评论:**<br/><br/>icholy: <pre><p>Looks like you're getting redirected </p>
<pre><code>HEAD /otn-pub/java/jdk/8u92-b14/jre-8u92-macosx-x64.dmg HTTP/1.1
Host: download.oracle.com
User-Agent: Go-http-client/1.1
Cookie: oraclelicense=accept-securebackup-cookie
HTTP/1.1 302 Moved Temporarily
Server: AkamaiGHost
Content-Length: 0
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u92-b14/jre-8u92-macosx-x64.dmg
Date: Wed, 29 Jun 2016 14:33:51 GMT
Connection: keep-alive
HEAD /errors/download-fail-1505220.html HTTP/1.1
Host: download.oracle.com
User-Agent: Go-http-client/1.1
HTTP/1.1 200 OK
Server: Apache
ETag: "81ee08846975d4b8d46acf3b6eddf103:1332282348"
Last-Modified: Tue, 20 Mar 2012 21:22:08 GMT
Accept-Ranges: bytes
Content-Length: 5307
Content-Type: text/html
Date: Wed, 29 Jun 2016 14:33:51 GMT
Connection: keep-alive
</code></pre></pre>KenjiTakahashi: <pre><p>Have you checked the contents of the file it serves you? It's probably giving you some kind of error page, which might contain useful details.</p></pre>positivedown: <pre><p>Didn't came into my mind, here you go: <a href="http://imgur.com/iS18zjV" rel="nofollow">http://imgur.com/iS18zjV</a>
Looks like the cookie stuff doesn't work as intended.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传