Created
November 11, 2018 05:39
-
-
Save kaneshin/727ac467f9146dd0a251ed94cbe8886d to your computer and use it in GitHub Desktop.
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 ( | |
"flag" | |
"fmt" | |
"net/http" | |
"os" | |
) | |
var ( | |
src = flag.String("url", "", "") | |
dst = flag.String("d", "", "destination") | |
) | |
var redirectPolicyFunc = func(req *http.Request, via []*http.Request) error { | |
return nil | |
} | |
func init() { | |
flag.Parse() | |
} | |
func main() { | |
client := &http.Client{ | |
CheckRedirect: redirectPolicyFunc, | |
} | |
resp, err := client.Get(*src) | |
if err != nil { | |
panic(err) | |
} | |
defer resp.Body.Close() | |
u := resp.Request.URL.String() | |
if u == *dst { | |
fmt.Println("ok") | |
os.Exit(0) | |
} | |
fmt.Println("ng") | |
os.Exit(1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment