Skip to content

Commit

Permalink
add GetHeaders to the Response interface (#3338)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 authored Oct 13, 2020
1 parent d3ab152 commit 21bad57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pkg/querier/queryrange/query_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ type Request interface {
// Response represents a query range response.
type Response interface {
proto.Message
// GetHeaders returns the HTTP headers in the response.
GetHeaders() []*PrometheusResponseHeader
}

type prometheusCodec struct{}
Expand Down
12 changes: 5 additions & 7 deletions pkg/querier/queryrange/results_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,12 @@ func (s resultsCache) shouldCacheResponse(ctx context.Context, r Response) bool
}

func getHeaderValuesWithName(r Response, headerName string) (headerValues []string) {
if promResp, ok := r.(*PrometheusResponse); ok {
for _, hv := range promResp.Headers {
if hv.GetName() != headerName {
continue
}

headerValues = append(headerValues, hv.GetValues()...)
for _, hv := range r.GetHeaders() {
if hv.GetName() != headerName {
continue
}

headerValues = append(headerValues, hv.GetValues()...)
}

return
Expand Down

0 comments on commit 21bad57

Please sign in to comment.