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:
@@ -96,7 +96,7 @@ func executeMiddleware(next http.RoundTripper, datasourceLabel prometheus.Labels
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if res != nil {
|
||||
if res != nil && res.StatusCode != http.StatusSwitchingProtocols {
|
||||
res.Body = httpclient.CountBytesReader(res.Body, func(bytesRead int64) {
|
||||
responseSizeSummary.Observe(float64(bytesRead))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user