package main
import (
"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
这样的设备上编译后运行也没报错,就是没反应
米琪卡哇伊
相关分类