mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
fix: set proxy url
This commit is contained in:
11
runner.go
11
runner.go
@@ -2,6 +2,7 @@ package hrp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -47,7 +48,15 @@ func (r *Runner) SetDebug(debug bool) *Runner {
|
|||||||
|
|
||||||
func (r *Runner) SetProxyUrl(proxyUrl string) *Runner {
|
func (r *Runner) SetProxyUrl(proxyUrl string) *Runner {
|
||||||
log.Info().Str("proxyUrl", proxyUrl).Msg("[init] SetProxyUrl")
|
log.Info().Str("proxyUrl", proxyUrl).Msg("[init] SetProxyUrl")
|
||||||
// TODO
|
p, err := url.Parse(proxyUrl)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Str("proxyUrl", proxyUrl).Msg("[init] invalid proxyUrl")
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
r.client.Transport = &http.Transport{
|
||||||
|
Proxy: http.ProxyURL(p),
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user