diff --git a/config.go b/config.go index 2cf82d4..b0edde1 100644 --- a/config.go +++ b/config.go @@ -47,6 +47,7 @@ type ModuleConfig struct { anomalyDuration time.Duration anomalySize int64 expectedContentTypes []string + extendContentTypes bool debug bool rawHeaderExtractor RawHeaderExtractorFunc inspector Inspector @@ -278,6 +279,15 @@ func ExpectedContentType(s string) ModuleConfigOption { } } +// ExtendContentTypes is a function argument to indicate that send request body +// of any content-type to the agent for inspection +func ExtendContentTypes(v bool) ModuleConfigOption { + return func(c *ModuleConfig) error { + c.extendContentTypes = v + return nil + } +} + // CustomInspector is a function argument that sets a custom inspector, // an optional inspector initializer to decide if inspection should occur, and // an optional inspector finalizer that can perform any post-inspection steps diff --git a/module.go b/module.go index e8b4457..88a04b4 100644 --- a/module.go +++ b/module.go @@ -385,6 +385,10 @@ func shouldReadBody(req *http.Request, m *Module) bool { return true } + if m.config.extendContentTypes { + return true + } + // read the body if there are multiple Content-Type headers if len(req.Header.Values("Content-Type")) > 1 { return true