Plugins: Refactor cleaning of call resource response headers (#67145)
First part of #66889 moving cleaning of call resource response headers within plugin management client.
This commit is contained in:
@@ -161,7 +161,6 @@ func (hs *HTTPServer) flushStream(stream callResourceClientResponseStream, w htt
|
||||
|
||||
// Expected that headers and status are only part of first stream
|
||||
if processedStreams == 0 {
|
||||
var hasContentType bool
|
||||
for k, values := range resp.Headers {
|
||||
// Convert the keys to the canonical format of MIME headers.
|
||||
// This ensures that we can safely add/overwrite headers
|
||||
@@ -169,15 +168,6 @@ func (hs *HTTPServer) flushStream(stream callResourceClientResponseStream, w htt
|
||||
// and be sure they won't be present multiple times in the response.
|
||||
k = textproto.CanonicalMIMEHeaderKey(k)
|
||||
|
||||
switch k {
|
||||
case "Set-Cookie":
|
||||
// Due to security reasons we don't want to forward
|
||||
// cookies from a backend plugin to clients/browsers.
|
||||
continue
|
||||
case "Content-Type":
|
||||
hasContentType = true
|
||||
}
|
||||
|
||||
for _, v := range values {
|
||||
// TODO: Figure out if we should use Set here instead
|
||||
// nolint:gocritic
|
||||
@@ -185,13 +175,6 @@ func (hs *HTTPServer) flushStream(stream callResourceClientResponseStream, w htt
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure a content type always is returned in response
|
||||
if !hasContentType && resp.Status != http.StatusNoContent {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
proxyutil.SetProxyResponseHeaders(w.Header())
|
||||
|
||||
w.WriteHeader(resp.Status)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user