[enh] ability to disable following redirections

pull/83/head
Adam Tauber 7 years ago
parent ed86f0e1ac
commit 3e3f1142e3

@ -38,6 +38,7 @@ type GeneralOptions struct {
FormatJSON bool
Insecure bool
PreserveScrollPosition bool
FollowRedirects bool
DefaultURLScheme string
}
@ -94,6 +95,7 @@ var DefaultConfig = Config{
FormatJSON: true,
Insecure: false,
PreserveScrollPosition: true,
FollowRedirects: true,
DefaultURLScheme: "https",
},
}

@ -5,6 +5,7 @@ defaultURLScheme = "https"
formatJSON = true
preserveScrollPosition = true
insecure = false
followRedirects = true
# KEYBINDINGS
[keys.global]

@ -1188,6 +1188,8 @@ func (a *App) ParseArgs(g *gocui.Gui, args []string) error {
}
case "-k", "--insecure":
a.config.General.Insecure = true
case "-R", "--disable-redirects":
a.config.General.FollowRedirects = false
case "-x", "--proxy":
if arg_index == args_len-1 {
return errors.New("Missing proxy URL")
@ -1269,6 +1271,11 @@ func (a *App) hasHeader(g *gocui.Gui, h string) bool {
func (a *App) InitConfig() {
CLIENT.Timeout = a.config.General.Timeout.Duration
TRANSPORT.TLSClientConfig = &tls.Config{InsecureSkipVerify: a.config.General.Insecure}
if !a.config.General.FollowRedirects {
CLIENT.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
}
}
}
func initApp(a *App, g *gocui.Gui) {
@ -1304,12 +1311,13 @@ func help() {
Usage: wuzz [-H|--header HEADER]... [-d|--data|--data-binary DATA] [-X|--request METHOD] [-t|--timeout MSECS] [URL]
Other command line options:
-c, --config PATH Specify custom configuration file
-h, --help Show this
-j, --json JSON Add JSON request data and set related request headers
-k, --insecure Allow insecure SSL certs
-v, --version Display version number
-x, --proxy URL Set HTTP(S) or SOCKS5 proxy
-c, --config PATH Specify custom configuration file
-h, --help Show this
-j, --json JSON Add JSON request data and set related request headers
-k, --insecure Allow insecure SSL certs
-R, --disable-redirects Do not follow HTTP redirects
-v, --version Display version number
-x, --proxy URL Set HTTP(S) or SOCKS5 proxy
Key bindings:
ctrl+r Send request

Loading…
Cancel
Save