mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(docker-proxy): reduce DB writes to optimize the proxy calls EE-5516 (#9148)
This commit is contained in:
parent
b37120802e
commit
74515f102d
7 changed files with 61 additions and 73 deletions
|
@ -77,7 +77,7 @@ func RewriteAccessDeniedResponse(response *http.Response) error {
|
|||
// RewriteResponse will replace the existing response body and status code with the one specified
|
||||
// in parameters
|
||||
func RewriteResponse(response *http.Response, newResponseData interface{}, statusCode int) error {
|
||||
data, err := marshal(getContentType(response.Header), newResponseData)
|
||||
data, err := marshal(getContentType(response), newResponseData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -98,14 +98,13 @@ func RewriteResponse(response *http.Response, newResponseData interface{}, statu
|
|||
|
||||
func getResponseBody(response *http.Response) (interface{}, error) {
|
||||
isGzip := response.Header.Get("Content-Encoding") == "gzip"
|
||||
|
||||
if isGzip {
|
||||
response.Header.Del("Content-Encoding")
|
||||
}
|
||||
|
||||
return getBody(response.Body, getContentType(response.Header), isGzip)
|
||||
return getBody(response.Body, getContentType(response), isGzip)
|
||||
}
|
||||
|
||||
func getContentType(headers http.Header) string {
|
||||
return headers.Get("Content-type")
|
||||
func getContentType(response *http.Response) string {
|
||||
return response.Header.Get("Content-type")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue