Skip to content

Commit 69d4f88

Browse files
Somefiveyue9944882
authored andcommitted
Feat: support hijacker for proxy resp writer
Signed-off-by: Yin Da <[email protected]>
1 parent 3cdb7b3 commit 69d4f88

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/apis/cluster/v1alpha1/clustergateway_proxy.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ var (
202202

203203
type proxyResponseWriter struct {
204204
http.ResponseWriter
205+
http.Hijacker
206+
http.Flusher
205207
statusCode int
206208
}
207209

@@ -210,8 +212,15 @@ func (in *proxyResponseWriter) WriteHeader(statusCode int) {
210212
in.ResponseWriter.WriteHeader(statusCode)
211213
}
212214

215+
func newProxyResponseWriter(_writer http.ResponseWriter) *proxyResponseWriter {
216+
writer := &proxyResponseWriter{ResponseWriter: _writer, statusCode: http.StatusOK}
217+
writer.Hijacker, _ = _writer.(http.Hijacker)
218+
writer.Flusher, _ = _writer.(http.Flusher)
219+
return writer
220+
}
221+
213222
func (p *proxyHandler) ServeHTTP(_writer http.ResponseWriter, request *http.Request) {
214-
writer := &proxyResponseWriter{_writer, http.StatusOK}
223+
writer := newProxyResponseWriter(_writer)
215224
defer func() {
216225
p.finishFunc(writer.statusCode)
217226
}()

0 commit comments

Comments
 (0)