Skip to content

Commit 9c40382

Browse files
committed
fix unit tests
1 parent cea5664 commit 9c40382

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

internal/cortex/querier/queryrange/query_bytes_fetched.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func QueryBytesFetchedPrometheusResponseHeaders(responses ...Response) []*Promet
4343
}
4444

4545
func QueryBytesFetchedHttpHeaderValue(response Response) []string {
46-
result := []string{}
46+
var result []string
4747
for _, hdr := range response.GetHeaders() {
4848
if hdr.GetName() == QueryBytesFetchedHeaderName {
4949
result = hdr.GetValues()

internal/cortex/querier/queryrange/query_range.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"context"
99
stdjson "encoding/json"
1010
"fmt"
11-
io "io"
11+
"io"
1212
"math"
1313
"net/http"
1414
"net/url"
@@ -447,11 +447,13 @@ func (prometheusCodec) EncodeResponse(ctx context.Context, res Response) (*http.
447447

448448
sp.LogFields(otlog.Int("bytes", len(b)))
449449

450+
httpHeader := http.Header{
451+
"Content-Type": []string{"application/json"}}
452+
if queryBytesFetchedHttpHeaderValue := QueryBytesFetchedHttpHeaderValue(res); queryBytesFetchedHttpHeaderValue != nil {
453+
httpHeader[QueryBytesFetchedHeaderName] = queryBytesFetchedHttpHeaderValue
454+
}
450455
resp := http.Response{
451-
Header: http.Header{
452-
"Content-Type": []string{"application/json"},
453-
QueryBytesFetchedHeaderName: QueryBytesFetchedHttpHeaderValue(res),
454-
},
456+
Header: httpHeader,
455457
Body: io.NopCloser(bytes.NewBuffer(b)),
456458
StatusCode: http.StatusOK,
457459
ContentLength: int64(len(b)),

0 commit comments

Comments
 (0)