Created
March 15, 2013 08:52
-
-
Save hantuo/5168439 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 "net/http" | |
func main() { | |
req, _ := http.NewRequest("GET", "http://localhost:12346/aaa", nil) | |
req.Header.Set("User-Agent", "abc") | |
http.DefaultClient.Do(req) | |
} | |
===========================第一个服务器 | |
package main | |
import ( | |
"net/http" | |
"log" | |
"os" | |
) | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
http.Redirect(w, r, "http://localhost:12347", 302) | |
}) | |
log.Fatal(http.ListenAndServe(os.Args[1], nil)) | |
} | |
================另一个服务端 | |
nc -l 12347 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment