Skip to content

Commit 1c7d02b

Browse files
committed
refactor: inverse HTTP cache (RFC 9111) logic (opt-in)
Signed-off-by: Dwi Siswanto <git@dw1.io>
1 parent 2ae9ce5 commit 1c7d02b

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

cmd/nuclei/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ on extensive configurability, massive extensibility and ease of use.`)
434434
}),
435435
flagSet.DurationVarP(&options.InputReadTimeout, "input-read-timeout", "irt", time.Duration(3*time.Minute), "timeout on input read"),
436436
flagSet.BoolVarP(&options.DisableHTTPProbe, "no-httpx", "nh", false, "disable httpx probing for non-url input"),
437-
flagSet.BoolVarP(&options.DisableHTTPCache, "no-http-cache", "nhc", false, "disable HTTP cache (RFC 9111) for HTTP requests"),
438437
flagSet.BoolVar(&options.DisableStdin, "no-stdin", false, "disable stdin processing"),
438+
flagSet.BoolVarP(&options.EnableHTTPCache, "http-cache", "hc", false, "enable HTTP cache (RFC 9111) for HTTP requests"),
439439
)
440440

441441
flagSet.CreateGroup("headless", "Headless",

pkg/protocols/http/httpclientpool/clientpool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func wrappedGet(options *types.Options, configuration *Configuration) (*retryabl
223223
if configuration.ResponseHeaderTimeout > 0 && configuration.ResponseHeaderTimeout > retryableHttpOptions.Timeout {
224224
retryableHttpOptions.Timeout = configuration.ResponseHeaderTimeout
225225
}
226-
if !options.DisableHTTPCache && !configuration.DisableHTTPCache {
226+
if options.EnableHTTPCache || !configuration.DisableHTTPCache {
227227
retryableHttpOptions.WrapTransport = httpcache.NewTransportWrapper()
228228
}
229229

pkg/types/types.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ type Options struct {
204204
DebugResponse bool
205205
// DisableHTTPProbe disables http probing feature of input normalization
206206
DisableHTTPProbe bool
207-
// DisableHTTPCache disables HTTP caching (RFC 9111) for requests
208-
DisableHTTPCache bool
207+
// EnableHTTPCache enables HTTP caching (RFC 9111) for requests
208+
//
209+
// NOTE(dwisiswant0): this is experimental and might be enabled by default
210+
// in the future releases.
211+
EnableHTTPCache bool
209212
// LeaveDefaultPorts skips normalization of default ports
210213
LeaveDefaultPorts bool
211214
// AutomaticScan enables automatic tech based template execution
@@ -559,7 +562,7 @@ func (options *Options) Copy() *Options {
559562
DebugRequests: options.DebugRequests,
560563
DebugResponse: options.DebugResponse,
561564
DisableHTTPProbe: options.DisableHTTPProbe,
562-
DisableHTTPCache: options.DisableHTTPCache,
565+
EnableHTTPCache: options.EnableHTTPCache,
563566
LeaveDefaultPorts: options.LeaveDefaultPorts,
564567
AutomaticScan: options.AutomaticScan,
565568
Silent: options.Silent,

0 commit comments

Comments
 (0)