Why Does My Go Http Client Get \'Your access to this site has been restricted\' Error on Github When Curl Works?

Mary-Kate Olsen
Release: 2024-10-29 14:49:02
Original
611 people have browsed it

Why Does My Go Http Client Get

"Github Your access to this site has been restricted" Using Go Http Client

When attempting to download zip or tar.gz files from Github using Go's http client, you may encounter the error message "Your access to this site has been restricted." Despite the error occurring with the Go client, curl may work without issue. This problem has been reported to occur on EC2 instances running Ubuntu Server 16.04 LTS in the us-west-2 region.

The following configuration details have been provided:

  • Go Version: 1.15.linux-amd64 (14 was also tried)
  • AWS: Ubuntu Server 16.04 LTS (HVM), SSD Volume Type - ami-0807918df10edc141 (64-bit x86) / ami-0c75fb2e6a6be38f6 (64-bit Arm)
  • Endpoint: https://github.com/kubeflow/manifests/archive/v1.0.2.tar.gz

Here is a sample code snippet that reproduces the issue:

<code class="go">package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    endpoint := "https://github.com/kubeflow/manifests/archive/v1.0.2.tar.gz"

    // Get the data
    resp, err := http.Get(endpoint)
    if err != nil {
        fmt.Printf("[error] %v", err)
        return
    }
    defer resp.Body.Close()

    respData, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        fmt.Printf("[error] %v", err)
        return
    }

    // Returns a 403 and html error page
    fmt.Printf("Resp:\n%v\n", string(respData))
}</code>
Copy after login

It's worth noting that the code runs successfully on local machines, suggesting that the issue is specific to the AWS instance.

Resolution:

A similar issue was encountered with the error message "Access to this site has been restricted." The solution involved updating the IDE (IntelliJ IDEA) and git version. This process can be completed directly within IntelliJ IDEA.

The above is the detailed content of Why Does My Go Http Client Get \'Your access to this site has been restricted\' Error on Github When Curl Works?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!