diff --git a/runner/options.go b/runner/options.go index 4f89b2c8..c3a29120 100644 --- a/runner/options.go +++ b/runner/options.go @@ -891,6 +891,14 @@ func (options *Options) ValidateOptions() error { options.Threads = defaultThreads } + // library callers skip flag defaults; a zero size would read and keep no body + if options.MaxResponseBodySizeToRead <= 0 { + options.MaxResponseBodySizeToRead = int(httpxcommon.DefaultMaxResponseBodySize) + } + if options.MaxResponseBodySizeToSave <= 0 { + options.MaxResponseBodySizeToSave = int(httpxcommon.DefaultMaxResponseBodySize) + } + return nil } diff --git a/runner/targetline_test.go b/runner/targetline_test.go index d0f91f38..4513fe25 100644 --- a/runner/targetline_test.go +++ b/runner/targetline_test.go @@ -707,10 +707,6 @@ func probe(t *testing.T, options *Options, inputs ...string) []Result { if options.Timeout == 0 { options.Timeout = 5 } - if options.MaxResponseBodySizeToRead == 0 { - options.MaxResponseBodySizeToRead = int(httpx.DefaultMaxResponseBodySize) - options.MaxResponseBodySizeToSave = int(httpx.DefaultMaxResponseBodySize) - } options.Methods = http.MethodGet options.InputTargetHost = inputs require.NoError(t, options.ValidateOptions()) @@ -737,3 +733,14 @@ func probe(t *testing.T, options *Options, inputs ...string) []Result { defer mu.Unlock() return results } + +func TestProbeDefaultOptionsReadBody(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte("body")) + })) + defer ts.Close() + + results := probe(t, &Options{OutputMatchCondition: `regex("html", body)`}, ts.URL) + require.Len(t, results, 1) + require.Equal(t, "body", results[0].ResponseBody) +}