Skip to content

Commit

Permalink
feat(executor/http): http Executor can be configured as "no follow re…
Browse files Browse the repository at this point in the history
…direct" (#175)

Signed-off-by: Romain Beuque <rbeuque74@gmail.com>
  • Loading branch information
rbeuque74 authored and yesnault committed Nov 14, 2018
1 parent 8acc350 commit ed86c4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion executors/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ In your yaml file, you can use:
- proxy optional: set to use a proxy server for connection to url
- ignore_verify_ssl optional: set to true if you use a self-signed SSL on remote for example
- basic_auth_user optional: username to use for HTTP basic authentification
- basic_auth_password optional: password to use for HTTP basic authentification
- basic_auth_password optional: password to use for HTTP basic authentification
- no_follow_redirect optional: indicates that you don't want to follow Location if server returns a Redirect (301/302/...)
- skip_body: skip the body and bodyjson result
- skip_headers: skip the headers result

Expand Down
6 changes: 6 additions & 0 deletions executors/http/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Executor struct {
SkipHeaders bool `json:"skip_headers" yaml:"skip_headers" mapstructure:"skip_headers"`
SkipBody bool `json:"skip_body" yaml:"skip_body" mapstructure:"skip_body"`
Proxy string `json:"proxy" yaml:"proxy" mapstructure:"proxy"`
NoFollowRedirect bool `json:"no_follow_redirect" yaml:"no_follow_redirect" mapstructure:"no_follow_redirect"`
}

// Result represents a step result. Json and yaml descriptor are used for json output
Expand Down Expand Up @@ -111,6 +112,11 @@ func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step
tr.Proxy = http.ProxyURL(proxyURL)
}
client := &http.Client{Transport: tr}
if e.NoFollowRedirect {
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
}

start := time.Now()
l.Debugf("http.Run.doRequest> Begin")
Expand Down

0 comments on commit ed86c4e

Please sign in to comment.