Skip to content

Instantly share code, notes, and snippets.

@Jeffwan
Created August 28, 2020 17:00
Show Gist options
  • Save Jeffwan/5f11afe8593950ed444c959160eb2822 to your computer and use it in GitHub Desktop.
Save Jeffwan/5f11afe8593950ed444c959160eb2822 to your computer and use it in GitHub Desktop.
Your access to this site has been restricted
```
curl -v https://github.com/kubeflow/manifests/archive/v1.0.2.tar.gz 09:55:14
* Trying 192.30.255.113...
* TCP_NODELAY set
* Connected to github.com (192.30.255.113) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=github.com
* start date: May 5 00:00:00 2020 GMT
* expire date: May 10 12:00:00 2022 GMT
* subjectAltName: host "github.com" matched cert's "github.com"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
* SSL certificate verify ok.
> GET /kubeflow/manifests/archive/v1.0.2.tar.gz HTTP/1.1
> Host: github.com
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 302 Found
< date: Fri, 28 Aug 2020 16:55:14 GMT
< content-type: text/html; charset=utf-8
< server: GitHub.com
< status: 302 Found
< vary: X-PJAX, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding
< location: https://codeload.github.com/kubeflow/manifests/tar.gz/v1.0.2
< cache-control: max-age=0, private
< strict-transport-security: max-age=31536000; includeSubdomains; preload
< x-frame-options: deny
< x-content-type-options: nosniff
< x-xss-protection: 1; mode=block
< expect-ct: max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"
< content-security-policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com www.githubstatus.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com cdn.optimizely.com logx.optimizely.com/v1/events wss://alive.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com; img-src 'self' data: github.githubassets.com identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com *.githubusercontent.com; manifest-src 'self'; media-src 'none'; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; worker-src github.com/socket-worker.js gist.github.com/socket-worker.js
< Content-Length: 126
< X-GitHub-Request-Id: 5F94:961A:813E9D:B511A8:5F49370D
<
* Connection #0 to host github.com left intact
<html><body>You are being <a href="https://codeload.github.com/kubeflow/manifests/tar.gz/v1.0.2">redirected</a>.</body></html>* Closing connection 0
```
This code snippet doesn't work
```
package main
import "net/http"
import "fmt"
import "io/ioutil"
func main() {
resp, _ := http.Get("https://github.com/aws/aws-sdk-go/archive/v1.27.1.tar.gz")
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Sprintf("Could not read response body; error %v", err)
}
fmt.Print(string(body))
}
```
This code snippet works fine.
```
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
client := &http.Client{}
req, err := http.NewRequest("GET", "https://github.com/aws/aws-sdk-go/archive/v1.27.1.tar.gz", nil)
if err != nil {
log.Fatalln(err)
}
req.Header.Set("User-Agent", "Golang_Spider_Bot/3.0")
resp, err := client.Do(req)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
log.Println("Doing copy")
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Sprintf("Could not read response body; error %v", err)
}
fmt.Print(len(body))
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment