Merge pull request #118 from iDevoid/redirect_restricted_mode_toggle

Redirect restricted mode shortcut toggle
pull/120/head
Adam Tauber 5 years ago committed by GitHub
commit 9e930188a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,6 +58,7 @@ Keybinding | Description
<kbd>F7</kbd> | Jump to search
<kbd>F8</kbd> | Jump to response headers
<kbd>F9</kbd> | Jump to response body
<kbd>F12</kbd> | Redirects Restriction Mode
### Context specific search

@ -74,6 +74,7 @@ var DefaultKeys = map[string]map[string]string{
"F7": "focus search",
"F8": "focus response-headers",
"F9": "focus response-body",
"F12": "redirects restriction mode",
},
"url": {
"Enter": "submit",
@ -106,7 +107,7 @@ var DefaultConfig = Config{
FormatJSON: true,
Insecure: false,
PreserveScrollPosition: true,
StatusLine: "[wuzz {{.Version}}]{{if .Duration}} [Response time: {{.Duration}}]{{end}} [Request no.: {{.RequestNumber}}/{{.HistorySize}}] [Search type: {{.SearchType}}]",
StatusLine: "[wuzz {{.Version}}]{{if .Duration}} [Response time: {{.Duration}}]{{end}} [Request no.: {{.RequestNumber}}/{{.HistorySize}}] [Search type: {{.SearchType}}]{{if .DisableRedirect}} [Redirects Restricted Mode {{.DisableRedirect}}]{{end}}",
Timeout: Duration{
defaultTimeoutDuration,
},

@ -31,6 +31,7 @@ F6 = "focus headers"
F7 = "focus search"
F8 = "focus response-headers"
F9 = "focus response-body"
F12 = "redirects restriction mode"
[keys.url]
Enter = "submit"

@ -57,6 +57,13 @@ func (s *StatusLine) Update(v *gocui.View, a *App) {
}
}
func (s *StatusLineFunctions) DisableRedirect() string {
if s.app.config.General.FollowRedirects {
return ""
}
return "Actived"
}
func NewStatusLine(format string) (*StatusLine, error) {
tpl, err := template.New("status line").Parse(format)
if err != nil {

@ -613,10 +613,7 @@ func (a *App) Layout(g *gocui.Gui) error {
setViewProperties(v, name)
}
}
sv, _ := g.View(STATUSLINE_VIEW)
sv.BgColor = gocui.ColorDefault | gocui.AttrReverse
sv.FgColor = gocui.ColorDefault | gocui.AttrReverse
a.statusLine.Update(sv, a)
refreshStatusLine(a, g)
return nil
}
@ -1099,6 +1096,12 @@ func (a *App) SetKeys(g *gocui.Gui) error {
return nil
})
g.SetKeybinding(ALL_VIEWS, gocui.KeyF12, gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error {
a.config.General.FollowRedirects = !a.config.General.FollowRedirects
refreshStatusLine(a, g)
return nil
})
g.SetKeybinding(REQUEST_METHOD_VIEW, gocui.KeyEnter, gocui.ModNone, a.ToggleMethodList)
cursDown := func(g *gocui.Gui, v *gocui.View) error {
@ -1749,13 +1752,21 @@ func (a *App) InitConfig() {
MinVersion: a.config.General.TLSVersionMin,
MaxVersion: a.config.General.TLSVersionMax,
}
if !a.config.General.FollowRedirects {
CLIENT.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
CLIENT.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
if a.config.General.FollowRedirects {
return nil
}
return http.ErrUseLastResponse
}
}
func refreshStatusLine(a *App, g *gocui.Gui) {
sv, _ := g.View(STATUSLINE_VIEW)
sv.BgColor = gocui.ColorDefault | gocui.AttrReverse
sv.FgColor = gocui.ColorDefault | gocui.AttrReverse
a.statusLine.Update(sv, a)
}
func initApp(a *App, g *gocui.Gui) {
g.Cursor = true
g.InputEsc = false

Loading…
Cancel
Save