This commit is contained in:
rui.zheng 2016-01-09 16:20:53 +08:00
parent ba3b1e8ef5
commit 3835ab437b

11
http.go
View File

@ -28,7 +28,6 @@ func handleHttpRequest(req *http.Request, conn net.Conn, arg Args) {
u, p, _ := basicAuth(req.Header.Get("Proxy-Authorization"))
req.Header.Del("Proxy-Authorization")
if (username != "" && u != username) || (password != "" && p != password) {
resp := "HTTP/1.1 407 Proxy Authentication Required\r\n" +
"Proxy-Authenticate: Basic realm=\"gost\"\r\n" +
@ -65,12 +64,10 @@ func handleHttpRequest(req *http.Request, conn net.Conn, arg Args) {
return
}
} else {
if len(forwardArgs) > 0 {
err = req.WriteProxy(c)
} else {
err = req.Write(c)
}
if err != nil {
req.Header.Del("Proxy-Connection")
req.Header.Set("Connection", "Keep-Alive")
if err = req.Write(c); err != nil {
glog.V(LWARNING).Infoln(err)
return
}