headzoo / surf

Stateful programmatic web browsing in Go.
MIT License
1.49k stars 160 forks source link

browser.Post() sends current URL as referrer #10

Closed mholt closed 9 years ago

mholt commented 9 years ago

Basically, I'm trying to send a request (by using browser.PostForm()) where, in order for it to succeed:

The most intuitive way to do this is just to make a browser with the SendReferer attribute set, then browser.Open() to the page that sets the cookie. Then I use browser.PostForm() to submit the request. The problem was that the Referer header wasn't being set because of that nil argument. This change makes it work all fine and dandy.

(I know I could just have done AddRequestHeader to set the referrer manually, but since the browser state is already on that page and SendReferer is true, this change just seems more intuitive. But I'm open to discussing it.)

girishso commented 9 years ago

+1 I also ran into this problem

headzoo commented 9 years ago

Good catch!