<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>
![](https://static.golangjob.cn/static/img/banner.png)