headzoo/surf — pull request #10 by mholt (2014-12-24 15:35:22+00:00)
Title: browser.Post() sends current URL as referrer

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

- A CSRF-related cookie must be obtained from the server by loading a page
- The CSRF token must be added in the request header
- The "Referer" header must be set to the proper value (the page which served the CSRF token)

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.)