mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-11-28 04:24:36 +03:00
Merge pull request #45 from projectdiscovery/42-bugfix
fixing host header
This commit is contained in:
commit
5e169282e9
@ -34,6 +34,7 @@ func main() {
|
||||
httpxOptions.FollowHostRedirects = options.FollowHostRedirects
|
||||
httpxOptions.HttpProxy = options.HttpProxy
|
||||
|
||||
var key, value string
|
||||
httpxOptions.CustomHeaders = make(map[string]string)
|
||||
for _, customHeader := range options.CustomHeaders {
|
||||
tokens := strings.Split(customHeader, ":")
|
||||
@ -41,8 +42,10 @@ func main() {
|
||||
if len(tokens) < 2 {
|
||||
continue
|
||||
}
|
||||
key = strings.TrimSpace(tokens[0])
|
||||
value = strings.TrimSpace(tokens[1])
|
||||
|
||||
httpxOptions.CustomHeaders[tokens[0]] = tokens[1]
|
||||
httpxOptions.CustomHeaders[key] = value
|
||||
}
|
||||
|
||||
hp, err := httpx.New(&httpxOptions)
|
||||
|
@ -92,14 +92,12 @@ func New(options *Options) (*HTTPX, error) {
|
||||
|
||||
// Do http request
|
||||
func (h *HTTPX) Do(req *retryablehttp.Request) (*Response, error) {
|
||||
var (
|
||||
resp Response
|
||||
)
|
||||
httpresp, err := h.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var resp Response
|
||||
resp.Headers = httpresp.Header.Clone()
|
||||
|
||||
// httputil.DumpResponse does not handle websockets
|
||||
@ -181,5 +179,9 @@ func (h *HTTPX) NewRequest(method, URL string) (req *retryablehttp.Request, err
|
||||
func (h *HTTPX) SetCustomHeaders(r *retryablehttp.Request, headers map[string]string) {
|
||||
for name, value := range headers {
|
||||
r.Header.Set(name, value)
|
||||
// host header is particular
|
||||
if strings.ToLower(name) == "host" {
|
||||
r.Host = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user