package mainimport ( "fmt" _"log" "io" "io/ioutil" _"net" _"strings" "net/http" _"net/url")func main() { http80()}func http80() { http.HandleFunc("/",handle80) http.ListenAndServe("0.0.0.0:80", nil)}func handle80(w http.ResponseWriter, req *http.Request) { proxyReq, _ := http.NewRequest("GET", "http://www.oschina.net", req.Body) client := &http.Client{} response, errorMsg := client.Do(proxyReq) if errorMsg != nil { fmt.Println(errorMsg) return } defer response.Body.Close() var newBody string = "" buffer, _ := ioutil.ReadAll(response.Body) newBody = string(buffer) io.WriteString(w, newBody)}這個在ubuntu14.04上可以運行的,可是在centos5.5
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux這樣的設備上編譯后運行也沒報錯,就是沒反應
- 2 回答
- 0 關注
- 1590 瀏覽
添加回答
舉報
0/150
提交
取消