assaf/zombie — pull request #425 by makeusabrew (2012-10-17 22:36:51+00:00)
Title: Ensure forms with GET method pass params to request URL

Bizarrely this doesn't appear to have really surfaced - admittedly a similar bug has been raised (#413) but it doesn't really get to the crux of the issue.

Essentially, a form with a method of GET was never actually submitting a proper query string of its data to the target URL. That is, even in the simplest case:

```

```

Any actual server side handling of the code would show an empty query string, or GET array (or however it handles such things). I originally noticed this in PHP but quickly verified that despite Zombie reporting the correct url with DEBUG=true (e.g. /foo/bar?my_param=my_value) Apache was not being passed the query string. As you'll see from the test, express doesn't / didn't either.

After lots of hunting it eventually boils down [to this](http://nodejs.org/docs/latest/api/http.html#http_http_request_options_callback) - specifically:
```path: Request path. Defaults to '/'. Should include query string if any. E.G. '/index.html?page=12'```

Whilst zombie was appending the query string to ```url.search```, this is not used by the request module nor the low-level node.js code, hence the server was never receiving a query string. I still can't quite believe that's the case - GET forms must be incredibly common - but it is the first time I've encountered it in many months usage of Zombie, and coincidentally enough all of the existing form tests are POST submissions.

I've added a test to verify the fix I've put in. I must admit the latest test suite does break for me when run in its entirety (sizzle throws errors about invalid selectors) so I've had to run this test pretty much in isolation (mocha test/forms_test.coffee --grep GET) so apologies if I've broken something elsewhere. In any case, the test highlights the issue.

Cheers,

Nick