|
| 1 | +diff --git a/vendor/go.opentelemetry.io/collector/config/confighttp/compression.go b/vendor/go.opentelemetry.io/collector/config/confighttp/compression.go |
| 2 | +index 88ecafe78..a700bec84 100644 |
| 3 | +--- a/vendor/go.opentelemetry.io/collector/config/confighttp/compression.go |
| 4 | ++++ b/vendor/go.opentelemetry.io/collector/config/confighttp/compression.go |
| 5 | +@@ -67,24 +67,26 @@ func (r *compressRoundTripper) RoundTrip(req *http.Request) (*http.Response, err |
| 6 | + } |
| 7 | + |
| 8 | + type decompressor struct { |
| 9 | +- errHandler func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int) |
| 10 | +- base http.Handler |
| 11 | +- decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error) |
| 12 | ++ errHandler func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int) |
| 13 | ++ base http.Handler |
| 14 | ++ decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error) |
| 15 | ++ maxRequestBodySize int64 |
| 16 | + } |
| 17 | + |
| 18 | + // httpContentDecompressor offloads the task of handling compressed HTTP requests |
| 19 | + // by identifying the compression format in the "Content-Encoding" header and re-writing |
| 20 | + // request body so that the handlers further in the chain can work on decompressed data. |
| 21 | + // It supports gzip and deflate/zlib compression. |
| 22 | +-func httpContentDecompressor(h http.Handler, eh func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int), decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error)) http.Handler { |
| 23 | ++func httpContentDecompressor(h http.Handler, maxRequestBodySize int64, eh func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int), decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error)) http.Handler { |
| 24 | + errHandler := defaultErrorHandler |
| 25 | + if eh != nil { |
| 26 | + errHandler = eh |
| 27 | + } |
| 28 | + |
| 29 | + d := &decompressor{ |
| 30 | +- errHandler: errHandler, |
| 31 | +- base: h, |
| 32 | ++ maxRequestBodySize: maxRequestBodySize, |
| 33 | ++ errHandler: errHandler, |
| 34 | ++ base: h, |
| 35 | + decoders: map[string]func(body io.ReadCloser) (io.ReadCloser, error){ |
| 36 | + "": func(io.ReadCloser) (io.ReadCloser, error) { |
| 37 | + // Not a compressed payload. Nothing to do. |
| 38 | +@@ -155,7 +157,7 @@ func (d *decompressor) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 39 | + // "Content-Length" is set to -1 as the size of the decompressed body is unknown. |
| 40 | + r.Header.Del("Content-Length") |
| 41 | + r.ContentLength = -1 |
| 42 | +- r.Body = newBody |
| 43 | ++ r.Body = http.MaxBytesReader(w, newBody, d.maxRequestBodySize) |
| 44 | + } |
| 45 | + d.base.ServeHTTP(w, r) |
| 46 | + } |
| 47 | +diff --git a/vendor/go.opentelemetry.io/collector/config/confighttp/confighttp.go b/vendor/go.opentelemetry.io/collector/config/confighttp/confighttp.go |
| 48 | +index b210fa0dd..71b2f17ee 100644 |
| 49 | +--- a/vendor/go.opentelemetry.io/collector/config/confighttp/confighttp.go |
| 50 | ++++ b/vendor/go.opentelemetry.io/collector/config/confighttp/confighttp.go |
| 51 | +@@ -30,6 +30,7 @@ import ( |
| 52 | + ) |
| 53 | + |
| 54 | + const headerContentEncoding = "Content-Encoding" |
| 55 | ++const defaultMaxRequestBodySize = 20 * 1024 * 1024 // 20MiB |
| 56 | + |
| 57 | + // ClientConfig defines settings for creating an HTTP client. |
| 58 | + type ClientConfig struct { |
| 59 | +@@ -269,7 +270,7 @@ type ServerConfig struct { |
| 60 | + // Auth for this receiver |
| 61 | + Auth *configauth.Authentication `mapstructure:"auth"` |
| 62 | + |
| 63 | +- // MaxRequestBodySize sets the maximum request body size in bytes |
| 64 | ++ // MaxRequestBodySize sets the maximum request body size in bytes. Default: 20MiB. |
| 65 | + MaxRequestBodySize int64 `mapstructure:"max_request_body_size"` |
| 66 | + |
| 67 | + // IncludeMetadata propagates the client metadata from the incoming requests to the downstream consumers |
| 68 | +@@ -340,7 +341,11 @@ func (hss *ServerConfig) ToServer(_ context.Context, host component.Host, settin |
| 69 | + o(serverOpts) |
| 70 | + } |
| 71 | + |
| 72 | +- handler = httpContentDecompressor(handler, serverOpts.errHandler, serverOpts.decoders) |
| 73 | ++ if hss.MaxRequestBodySize <= 0 { |
| 74 | ++ hss.MaxRequestBodySize = defaultMaxRequestBodySize |
| 75 | ++ } |
| 76 | ++ |
| 77 | ++ handler = httpContentDecompressor(handler, hss.MaxRequestBodySize, serverOpts.errHandler, serverOpts.decoders) |
| 78 | + |
| 79 | + if hss.MaxRequestBodySize > 0 { |
| 80 | + handler = maxRequestBodySizeInterceptor(handler, hss.MaxRequestBodySize) |
0 commit comments