Created
March 3, 2016 10:17
-
-
Save s-aska/0badbf1d7c3e49b9790f to your computer and use it in GitHub Desktop.
🔫 Don't redirect !!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import( | |
"errors" | |
"fmt" | |
"net/http" | |
) | |
var RedirectAttemptedError = errors.New("redirect") | |
var nopasteClient = func() (*http.Client) { | |
var client = &http.Client{} | |
client.CheckRedirect = func(req *http.Request, via []*http.Request) error { | |
return RedirectAttemptedError | |
} | |
return client | |
}() | |
func main() { | |
resp, _ := nopasteClient.Get("https://goo.gl/xqt7hT") | |
url, _ := resp.Location() | |
if url != nil { | |
fmt.Println(url.String()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment