Skip to content

Commit

Permalink
HACK: store all response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vrutkovs committed Oct 24, 2024
1 parent 26df186 commit 1cf4aa6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/endpoints/filters/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package filters
import (
"bufio"
"context"
"encoding/json"
"errors"
"fmt"
"net"
Expand Down Expand Up @@ -254,12 +255,22 @@ func (a *auditResponseWriter) Header() http.Header {
a.event.Annotations["openshift.io/response-header-content-length"] = strings.Join(value, ",")
}
}
headers, err := json.Marshal(a.ResponseWriter.Header())
if err == nil {
if a.event.Annotations == nil {
a.event.Annotations = make(map[string]string)
}
a.event.Annotations["openshift.io/response-headers"] = string(headers)
}
return a.ResponseWriter.Header()
}

func (a *auditResponseWriter) Write(bs []byte) (int, error) {
// the Go library calls WriteHeader internally if no code was written yet. But this will go unnoticed for us
a.processCode(http.StatusOK)
if a.event.Annotations == nil {
a.event.Annotations = make(map[string]string)
}
if _, ok := a.event.Annotations["openshift.io/response-header-content-length"]; !ok {
a.event.Annotations["openshift.io/response-header-content-length"] = fmt.Sprintf("%d", len(bs))
}
Expand Down

0 comments on commit 1cf4aa6

Please sign in to comment.