Browse Source

Disable http CheckRedirect

master
Teran McKinney 2 years ago
parent
commit
bf8ffbcb02
  1. 10
      onion.go

10
onion.go

@ -8,6 +8,12 @@ import (
"golang.org/x/net/proxy"
)
// This also disables redirect handling.
func checkRedirect(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
}
func isOnion(someURL string) (bool, error) {
parsedURL, err := url.Parse(someURL)
if err != nil {
@ -32,7 +38,7 @@ func onionHTTP() (client *http.Client, err error) {
return
}
torTransport := &http.Transport{Dial: torDialer.Dial}
client = &http.Client{Transport: torTransport}
client = &http.Client{Transport: torTransport, CheckRedirect: checkRedirect}
return
}
@ -46,7 +52,7 @@ func clearnetOrOnionHTTP(url string) (client *http.Client, err error) {
if reallyIsOnion {
client, err = onionHTTP()
} else {
client = &http.Client{}
client = &http.Client{CheckRedirect: checkRedirect}
}
return
}
Loading…
Cancel
Save