Skip to content

Commit eeb44e5

Browse files
committed
Added config option to send request body of any content type to agent
1 parent d5a7ec3 commit eeb44e5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type ModuleConfig struct {
4747
anomalyDuration time.Duration
4848
anomalySize int64
4949
expectedContentTypes []string
50+
extendContentTypes bool
5051
debug bool
5152
rawHeaderExtractor RawHeaderExtractorFunc
5253
inspector Inspector
@@ -278,6 +279,15 @@ func ExpectedContentType(s string) ModuleConfigOption {
278279
}
279280
}
280281

282+
// ExtendContentTypes is a function argument to indicate that send request body
283+
// of any content-type to the agent for inspection
284+
func ExtendContentTypes(v bool) ModuleConfigOption {
285+
return func(c *ModuleConfig) error {
286+
c.extendContentTypes = v
287+
return nil
288+
}
289+
}
290+
281291
// CustomInspector is a function argument that sets a custom inspector,
282292
// an optional inspector initializer to decide if inspection should occur, and
283293
// an optional inspector finalizer that can perform any post-inspection steps

module.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ func shouldReadBody(req *http.Request, m *Module) bool {
385385
return true
386386
}
387387

388+
if m.config.extendContentTypes {
389+
return true
390+
}
391+
388392
// read the body if there are multiple Content-Type headers
389393
if len(req.Header.Values("Content-Type")) > 1 {
390394
return true

0 commit comments

Comments
 (0)