@@ -22,7 +22,6 @@ import (
2222 "github.com/weaveworks/common/httpgrpc/server"
2323 "google.golang.org/grpc/status"
2424
25- "github.com/cortexproject/cortex/pkg/ingester/client"
2625 querier_stats "github.com/cortexproject/cortex/pkg/querier/stats"
2726 "github.com/cortexproject/cortex/pkg/querier/tripperware"
2827 "github.com/cortexproject/cortex/pkg/tenant"
@@ -143,22 +142,15 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
143142 r .Body = io .NopCloser (io .TeeReader (r .Body , & buf ))
144143 // We parse form here so that we can use buf as body, in order to
145144 // prevent https://github.com/cortexproject/cortex/issues/5201.
146- if strings .Contains (r .URL .Path , "api/v1/read" ) {
147- var req client.ReadRequest
148- if err := util .ParseProtoReader (r .Context (), r .Body , int (r .ContentLength ), maxRemoteReadQuerySize , & req , util .RawSnappy ); err != nil {
149- level .Error (util_log .WithContext (r .Context (), f .log )).Log ("msg" , "failed to parse proto" , "err" , err .Error ())
150- http .Error (w , err .Error (), http .StatusBadRequest )
151- return
152- }
153- } else {
145+ // Exclude remote read here as we don't have to buffer its body.
146+ if ! strings .Contains (r .URL .Path , "api/v1/read" ) {
154147 if err := r .ParseForm (); err != nil {
155148 writeError (w , err )
156149 return
157150 }
151+ r .Body = io .NopCloser (& buf )
158152 }
159153
160- r .Body = io .NopCloser (& buf )
161-
162154 startTime := time .Now ()
163155 resp , err := f .roundTripper .RoundTrip (r )
164156 queryResponseTime := time .Since (startTime )
0 commit comments