2022-02-28

Using curl to download golang tarball produces strange result

I was trying to install golang on Ubuntu 21.10. This requires downloading the golang tarball and extracting it to a particular place on the filesystem. First I tried:

curl -O https://go.dev/dl/go1.17.7.linux-amd64.tar.gz

which simply created a file with following text:

<a href="https://dl.google.com/go/go1.17.7.linux-amd64.tar.gz">Found</a>.

The same command output with verbose flag :

$ curl -v https://go.dev/dl/go1.17.7.linux-amd64.tar.gz
*   Trying 216.239.32.21:443...
* Connected to go.dev (216.239.32.21) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=go.dev
*  start date: Feb 11 11:23:46 2022 GMT
*  expire date: May 12 11:23:45 2022 GMT
*  subjectAltName: host "go.dev" matched cert's "go.dev"
*  issuer: C=US; O=Google Trust Services LLC; CN=GTS CA 1D4
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55726a1bb5e0)
> GET /dl/go1.17.7.linux-amd64.tar.gz HTTP/2
> Host: go.dev
> user-agent: curl/7.74.0
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 302
< content-type: text/html; charset=utf-8
< content-security-policy: connect-src 'self' www.google-analytics.com stats.g.doubleclick.net ; default-src 'self' ; font-src 'self' fonts.googleapis.com fonts.gstatic.com data: ; frame-ancestors 'self' ; frame-src 'self' www.google.com feedback.googleusercontent.com www.googletagmanager.com scone-pa.clients6.google.com www.youtube.com player.vimeo.com ; img-src 'self' www.google.com www.google-analytics.com ssl.gstatic.com www.gstatic.com gstatic.com data: * ; object-src 'none' ; script-src 'self' 'sha256-n6OdwTrm52KqKm6aHYgD0TFUdMgww4a0GQlIAVrMzck=' 'sha256-4ryYrf7Y5daLOBv0CpYtyBIcJPZkRD2eBPdfqsN3r1M=' 'sha256-sVKX08+SqOmnWhiySYk3xC7RDUgKyAkmbXV2GWts4fo=' www.google.com apis.google.com www.gstatic.com gstatic.com support.google.com www.googletagmanager.com www.google-analytics.com ssl.google-analytics.com tagmanager.google.com ; style-src 'self' 'unsafe-inline' fonts.googleapis.com feedback.googleusercontent.com www.gstatic.com gstatic.com tagmanager.google.com ;
< location: https://dl.google.com/go/go1.17.7.linux-amd64.tar.gz
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< x-cloud-trace-context: 7611c1786413210c614a80a1da377a17
< date: Thu, 24 Feb 2022 05:02:13 GMT
< server: Google Frontend
< content-length: 75
<
<a href="https://dl.google.com/go/go1.17.7.linux-amd64.tar.gz">Found</a>.

* Connection #0 to host go.dev left intact

The tarball download works fine with wget command. I tried reading more about the difference between the two and feel that the curl should have worked. I never had issues with using curl before when downloading archives for e.g., linux source tarball. I am really not sure if the issue is with the curl or the golang server. Any explanation would be helpful.



No comments:

Post a Comment