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 关注
- 1561 浏览
添加回答
举报
0/150
提交
取消