Skip to content

Commit 21bad57

Browse files
authored
add GetHeaders to the Response interface (#3338)
Signed-off-by: Ben Ye <[email protected]>
1 parent d3ab152 commit 21bad57

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/querier/queryrange/query_range.go

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ type Request interface {
8787
// Response represents a query range response.
8888
type Response interface {
8989
proto.Message
90+
// GetHeaders returns the HTTP headers in the response.
91+
GetHeaders() []*PrometheusResponseHeader
9092
}
9193

9294
type prometheusCodec struct{}

pkg/querier/queryrange/results_cache.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,12 @@ func (s resultsCache) shouldCacheResponse(ctx context.Context, r Response) bool
255255
}
256256

257257
func getHeaderValuesWithName(r Response, headerName string) (headerValues []string) {
258-
if promResp, ok := r.(*PrometheusResponse); ok {
259-
for _, hv := range promResp.Headers {
260-
if hv.GetName() != headerName {
261-
continue
262-
}
263-
264-
headerValues = append(headerValues, hv.GetValues()...)
258+
for _, hv := range r.GetHeaders() {
259+
if hv.GetName() != headerName {
260+
continue
265261
}
262+
263+
headerValues = append(headerValues, hv.GetValues()...)
266264
}
267265

268266
return

0 commit comments

Comments
 (0)