Skip to content

Instantly share code, notes, and snippets.

@hantuo
Created March 15, 2013 08:52
Show Gist options
  • Save hantuo/5168439 to your computer and use it in GitHub Desktop.
Save hantuo/5168439 to your computer and use it in GitHub Desktop.
=========================客户端
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