Skip to content

Commit

Permalink
gotip: don't set User-Agent for http.DefaultTransport
Browse files Browse the repository at this point in the history
This code was copied from ./internal/version in CL 206537 with the
intention of making the gotip command more consistent with the other
golang.org/dl/go... commands. However, the gotip command does not
use net/http at all, so setting a custom user agent has no effect.

Change-Id: I1632aa5f01d9c1a2541219d2649d7dc57ac259b5
Reviewed-on: https://go-review.googlesource.com/c/dl/+/207097
Reviewed-by: Bryan C. Mills <[email protected]>
Run-TryBot: Dmitri Shuralyov <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
dmitshur committed Dec 20, 2019
1 parent 1cf0f0c commit 84da647
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions gotip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"errors"
"fmt"
"log"
"net/http"
"os"
"os/exec"
"os/user"
Expand All @@ -27,10 +26,6 @@ import (
"strings"
)

func init() {
http.DefaultTransport = &userAgentTransport{http.DefaultTransport}
}

func main() {
log.SetFlags(0)

Expand Down Expand Up @@ -186,15 +181,6 @@ func homedir() (string, error) {
}
}

type userAgentTransport struct {
rt http.RoundTripper
}

func (uat userAgentTransport) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Set("User-Agent", "golang-x-build-version/devel")
return uat.rt.RoundTrip(r)
}

// dedupEnv returns a copy of env with any duplicates removed, in favor of
// later values.
// Items are expected to be on the normal environment "key=value" form.
Expand Down

0 comments on commit 84da647

Please sign in to comment.