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