Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fail_if_body_too_large http probe option #1276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hashworks
Copy link

This can be used in conjunction with body_size_limit when it is expected that endpoints return a body larger than the specified limit, e.g. streaming endpoints that potentially return infinite data.

@hashworks hashworks force-pushed the feature/fail_if_body_too_large branch from 81b9317 to 1e0ff2b Compare August 6, 2024 09:40
@@ -550,7 +550,7 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr

if !requestErrored {
_, err = io.Copy(io.Discard, byteCounter)
if err != nil {
if err != nil && (errors.Is(err, &http.MaxBytesError{}) || httpConfig.GetFailIfBodyTooLarge()) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if this is okay or if I should move this to another if so it's clearer.

@@ -450,6 +451,13 @@ func (s *HeaderMatch) UnmarshalYAML(unmarshal func(interface{}) error) error {
return nil
}

func (h HTTPProbe) GetFailIfBodyTooLarge() bool {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively I could do the nil check in UnmarshalYAML, but then it could panic if someone changes the variable under the hood later on.

This can be used in conjunction with `body_size_limit` when it is
expected that endpoints return a body larger than the specified limit,
e.g. streaming endpoints that potentially return infinite data.

Signed-off-by: Justin Kromlinger <[email protected]>
@hashworks hashworks force-pushed the feature/fail_if_body_too_large branch from 1e0ff2b to 2d225ab Compare November 1, 2024 13:36
@hashworks
Copy link
Author

Do you want any changes here? Or is this a feature you don't want merged?

@hashworks hashworks force-pushed the feature/fail_if_body_too_large branch from 2a3f154 to 1512b95 Compare November 1, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant