@@ -53,13 +53,21 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
53
53
http .Error (w , "hijacking not supported" , http .StatusInternalServerError )
54
54
return
55
55
}
56
- w .WriteHeader (http .StatusOK )
57
56
58
57
conn , bufrw , err := hijacker .Hijack ()
59
58
if err != nil {
60
59
http .Error (w , err .Error (), http .StatusInternalServerError )
61
60
return
62
61
}
62
+
63
+ // Send the HTTP 200 OK status after a successful hijack
64
+ _ , err = conn .Write ([]byte ("HTTP/1.1 200 Connection Established\r \n \r \n " ))
65
+ if err != nil {
66
+ klog .ErrorS (err , "failed to send 200 connection established" )
67
+ conn .Close ()
68
+ return
69
+ }
70
+
63
71
var closeOnce sync.Once
64
72
defer closeOnce .Do (func () { conn .Close () })
65
73
@@ -78,7 +86,9 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
78
86
klog .V (4 ).Infof ("Set pending(rand=%d) to %v" , random , w )
79
87
backend , err := t .Server .getBackend (r .Host )
80
88
if err != nil {
81
- http .Error (w , fmt .Sprintf ("currently no tunnels available: %v" , err ), http .StatusInternalServerError )
89
+ klog .ErrorS (err , "no tunnels available" )
90
+ conn .Write ([]byte (fmt .Sprintf ("HTTP/1.1 500 Internal Server Error\r \n Content-Type: text/plain\r \n \r \n currently no tunnels available: %v" , err )))
91
+ conn .Close ()
82
92
return
83
93
}
84
94
closed := make (chan struct {})
0 commit comments