Skip to content

Commit

Permalink
Merge pull request kubernetes#46854 from CaoShuFeng/jijacker
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 46897, 46899, 46864, 46854, 46875)

[advanced audit] fix invalid status code for hijacker

Fixes kubernetes#47035

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.

Part of kubernetes/enhancements#22
  • Loading branch information
Kubernetes Submit Queue authored Jun 6, 2017
2 parents f04a774 + 541935b commit 5633d75
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion staging/src/k8s.io/apiserver/pkg/endpoints/filters/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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()
}

Expand Down

0 comments on commit 5633d75

Please sign in to comment.