Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return nil
}

Expand Down
15 changes: 11 additions & 4 deletions runner/targetline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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("<html>body</html>"))
}))
defer ts.Close()

results := probe(t, &Options{OutputMatchCondition: `regex("html", body)`}, ts.URL)
require.Len(t, results, 1)
require.Equal(t, "<html>body</html>", results[0].ResponseBody)
}
Loading