refactor: inverse HTTP cache (RFC 9111) logic (opt-in)

Signed-off-by: Dwi Siswanto <git@dw1.io>
This commit is contained in:
Dwi Siswanto
2026-01-21 18:57:21 +07:00
parent 2ae9ce5324
commit fd513ffb5e
3 changed files with 8 additions and 5 deletions

View File

@@ -434,8 +434,8 @@ on extensive configurability, massive extensibility and ease of use.`)
}),
flagSet.DurationVarP(&options.InputReadTimeout, "input-read-timeout", "irt", time.Duration(3*time.Minute), "timeout on input read"),
flagSet.BoolVarP(&options.DisableHTTPProbe, "no-httpx", "nh", false, "disable httpx probing for non-url input"),
flagSet.BoolVarP(&options.DisableHTTPCache, "no-http-cache", "nhc", false, "disable HTTP cache (RFC 9111) for HTTP requests"),
flagSet.BoolVar(&options.DisableStdin, "no-stdin", false, "disable stdin processing"),
flagSet.BoolVar(&options.EnableHTTPCache, "http-cache", false, "enable HTTP cache (RFC 9111) for HTTP requests"),
)
flagSet.CreateGroup("headless", "Headless",

View File

@@ -223,7 +223,7 @@ func wrappedGet(options *types.Options, configuration *Configuration) (*retryabl
if configuration.ResponseHeaderTimeout > 0 && configuration.ResponseHeaderTimeout > retryableHttpOptions.Timeout {
retryableHttpOptions.Timeout = configuration.ResponseHeaderTimeout
}
if !options.DisableHTTPCache && !configuration.DisableHTTPCache {
if options.EnableHTTPCache && !configuration.DisableHTTPCache {
retryableHttpOptions.WrapTransport = httpcache.NewTransportWrapper()
}

View File

@@ -204,8 +204,11 @@ type Options struct {
DebugResponse bool
// DisableHTTPProbe disables http probing feature of input normalization
DisableHTTPProbe bool
// DisableHTTPCache disables HTTP caching (RFC 9111) for requests
DisableHTTPCache bool
// EnableHTTPCache enables HTTP caching (RFC 9111) for requests
//
// NOTE(dwisiswant0): this is experimental and might be enabled by default
// in the future releases.
EnableHTTPCache bool
// LeaveDefaultPorts skips normalization of default ports
LeaveDefaultPorts bool
// AutomaticScan enables automatic tech based template execution
@@ -559,7 +562,7 @@ func (options *Options) Copy() *Options {
DebugRequests: options.DebugRequests,
DebugResponse: options.DebugResponse,
DisableHTTPProbe: options.DisableHTTPProbe,
DisableHTTPCache: options.DisableHTTPCache,
EnableHTTPCache: options.EnableHTTPCache,
LeaveDefaultPorts: options.LeaveDefaultPorts,
AutomaticScan: options.AutomaticScan,
Silent: options.Silent,