From 75c3cb0fcc14ceed67f119b8f8d7da3ccee87272 Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Tue, 17 Jul 2018 19:29:37 +0800 Subject: [PATCH] fix crash --- handler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index 13da806..a704976 100644 --- a/handler.go +++ b/handler.go @@ -160,7 +160,12 @@ func (h *handler) handleCONNECT(w http.ResponseWriter, r *http.Request) { if r.ProtoMajor == 1 { // HTTP/1.1 - hj, _ := w.(http.Hijacker) + hj, ok := w.(http.Hijacker) + if !ok { + w.WriteHeader(http.StatusNotFound) + return + } + conn1, _, _ := hj.Hijack() fmt.Fprintf(conn1, "%s 200 connection established\r\n\r\n", r.Proto)