Skip to content

Commit

Permalink
Added config option to send request body of any content type to agent
Browse files Browse the repository at this point in the history
  • Loading branch information
sada-sigsci committed Jun 27, 2023
1 parent d5a7ec3 commit eeb44e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type ModuleConfig struct {
anomalyDuration time.Duration
anomalySize int64
expectedContentTypes []string
extendContentTypes bool
debug bool
rawHeaderExtractor RawHeaderExtractorFunc
inspector Inspector
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eeb44e5

Please sign in to comment.