headzoo / surf

Stateful programmatic web browsing in Go.
MIT License
1.48k stars 159 forks source link

I can't manual set user agent when page redirect #37

Closed ghost closed 7 years ago

ghost commented 8 years ago

Hello sir: sorry, my English is very bad, I use Google Translate. When the page redirects happen, user agent will be reset. Please add following line in your source browser.go.

func (bow Browser) shouldRedirect(req *http.Request, []_http.Request) error { if bow.attributes[FollowRedirects] { req.Header.Set("User-Agent", bow.userAgent) return nil } return errors.NewLocation( "Redirects are disabled. Cannot follow '%s'.", req.URL.String()) }

lxt2 commented 8 years ago

This is actually a fairly serious issue. The user agent leaks on redirects as User-Agent: Go-http-client/1.1.

lxt2 commented 8 years ago

Fixed in https://github.com/cardigann/surf/commit/7ce0920552c70dae633192a73923ed71d9f899ef