mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataProxy: Fix issue overriding response body when response status is 101 (#41364)
When a request going through Grafana data source proxy responds with a websocket upgrade response we cannot override the response body since it produces an error. This problem seems to have been introduced in Grafana v8.0 by #38962. In addition #40303 added same problem. Fixes #41292
This commit is contained in:
parent
cd5d84b0f3
commit
3be452f995
@ -96,7 +96,7 @@ func executeMiddleware(next http.RoundTripper, datasourceLabel prometheus.Labels
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if res != nil {
|
if res != nil && res.StatusCode != http.StatusSwitchingProtocols {
|
||||||
res.Body = httpclient.CountBytesReader(res.Body, func(bytesRead int64) {
|
res.Body = httpclient.CountBytesReader(res.Body, func(bytesRead int64) {
|
||||||
responseSizeSummary.Observe(float64(bytesRead))
|
responseSizeSummary.Observe(float64(bytesRead))
|
||||||
})
|
})
|
||||||
|
@ -21,7 +21,10 @@ func ResponseLimitMiddleware(limit int64) sdkhttpclient.Middleware {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Body = httpclient.MaxBytesReader(res.Body, limit)
|
if res != nil && res.StatusCode != http.StatusSwitchingProtocols {
|
||||||
|
res.Body = httpclient.MaxBytesReader(res.Body, limit)
|
||||||
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user