headzoo / surf

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

Add support for calling Browser.Post from initial state #14

Closed Mojofreem closed 9 years ago

Mojofreem commented 9 years ago

The Post method of Browser references bow.Url(), which implies that the browser instance has already established a connection (via a GET call?) prior to the POST call. This causes a nil pointer dereference if you attempt to make a Post call with a newly instantiated Browser instance. My current workaround is to make a dummy get call to the same url prior to the POST call.

headzoo commented 9 years ago

Sounds like a good fix. So far my general philosophy has been to treat Surf like a real browser, and generally with real browsers a POST request follows a GET request, which is knowledge used by web developers to block spiders and bots that POST to forms without first making a GET request for the page containing the form. But Surf wouldn't be useful if we rigidly stick to the "real browser" way of thinking, so I don't see a problem with starting a session with a POST request.

I'll take a look at making the change today.

headzoo commented 9 years ago

This has been fixed in the latest master.