Package Mainimport ("FMT" "io" "net/http") func Main () {http. Handlefunc ("/", route) E: = http. Listenandserve (": +", nil) if E! = nil {fmt. Println (e)}}func Route (W http. Responsewriter, R *http. Request) {req, _: = http. Newrequest (R.method, "", R.body) req. URL = R.urlreq.url.host = r.host//"www.qq.com" req. Url. Scheme = "http" for _, V: = Range r.cookies () {req. Addcookie (v)}//req. Header = R.header The header here will not be used, if used, he will automatically jump to HTTPS, the agent has a problem. RESP, err: = http. Defaultclient.do (req) If err! = Nil {fmt. Println ("Here:", err) Return}for k, V: = Range resp. Header {For _, Value: = Range v {w.header (). ADD (k, value)}}for _, Cookie: = Range resp. Cookies () {W.header (). ADD ("Set-cookie", cookies. Raw)}w.writeheader (resp. StatusCode) io. Copy (W, resp. Body) resp. Body.close () R.body.close ()}
This is used to visit overseas sites, to the local host, the domain name binding to IP, for example: 1.1.1.1 www.google.com
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Use go to write a proxy-like applet, can be used to access Goolge personal use or can.