fix invalid status code for hijacker

When using hijacker to take over the connection, the http status code
should be 101 not 200.

PS:
Use "kubectl exec" as an example to review this change.

Kubernetes-commit: 541935b13f87e55199840a73cd3f158e7f0d7b63
This commit is contained in:
Cao Shufeng 2017-06-02 20:03:49 +08:00 committed by Kubernetes Publisher
parent e10c78ea7c
commit 42b5738617
1 changed files with 3 additions and 1 deletions

View File

@ -177,7 +177,7 @@ func (a *auditResponseWriter) processCode(code int) {
}
func (a *auditResponseWriter) Write(bs []byte) (int, error) {
a.processCode(200) // the Go library calls WriteHeader internally if no code was written yet. But this will go unnoticed for us
a.processCode(http.StatusOK) // the Go library calls WriteHeader internally if no code was written yet. But this will go unnoticed for us
return a.ResponseWriter.Write(bs)
}
@ -202,6 +202,8 @@ func (f *fancyResponseWriterDelegator) Flush() {
}
func (f *fancyResponseWriterDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
// fake a response status before protocol switch happens
f.processCode(http.StatusSwitchingProtocols)
return f.ResponseWriter.(http.Hijacker).Hijack()
}