From 939a8cee96452d0aa827df8728f0f2d23898fbd0 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 19 Jan 2019 08:36:22 -0500 Subject: [PATCH] more --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index ab9703d..3e7bcb7 100644 --- a/main.go +++ b/main.go @@ -42,14 +42,19 @@ func (h *httpProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } hijacker, ok := w.(http.Hijacker) if !ok { + outConn.Close() http.Error(w, "hijack disallowed", http.StatusInternalServerError) return } conn, _, err := hijacker.Hijack() if err != nil { + outConn.Close() http.Error(w, err.Error(), http.StatusServiceUnavailable) return } + w.WriteHeader(http.StatusOK) + go transfer(conn, outConn) + go transfer(outConn, conn) } else { w.WriteHeader(http.StatusMethodNotAllowed) }