Skip to content

Commit

Permalink
Respect passed headers in read path requests (#4287)
Browse files Browse the repository at this point in the history
  • Loading branch information
mapno authored Nov 5, 2024
1 parent c0fb6be commit 3449ef6
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions modules/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,9 @@ func newMetricsSummaryHandler(next pipeline.AsyncRoundTripper[combiner.PipelineR
// cloneRequestforQueriers returns a cloned pipeline.Request from the passed pipeline.Request ready for queriers. The caller is given an opportunity
// to modify the internal http.Request before it is returned using the modHTTP param. If modHTTP is nil, the internal http.Request is returned.
func cloneRequestforQueriers(parent pipeline.Request, tenant string, modHTTP func(*http.Request) (*http.Request, error)) (pipeline.Request, error) {
// first clone the http request with headers nil'ed out. this prevents the headers from being copied saving allocs
// here and especially downstream in the httpgrpc bridge. prepareRequestForQueriers will add the only headers that
// the queriers actually need.
req := parent.HTTPRequest()
saveHeaders := req.Header
req.Header = nil
clonedHTTPReq := req.Clone(req.Context())

req.Header = saveHeaders
clonedHTTPReq.Header = make(http.Header, 2) // cheating here. alloc 2 b/c we know that's how many headers prepareRequestForQueriers will add

// give the caller a chance to modify the internal http request
if modHTTP != nil {
var err error
Expand Down

0 comments on commit 3449ef6

Please sign in to comment.