keplerproject/wsapi — pull request #13 by ignacio (2013-04-19 15:22:16+00:00)
Title: wsapi.request.qs_encode yields invalid querystrings

According to [RFC 3875](http://www.ietf.org/rfc/rfc3875), the question mark is not part of the querystring.

This code fails because the first key-value pair is missing:

~~~lua
local mock = require "wsapi.mock"
local ws_request = require "wsapi.request"

local test_app = function(wsapi_env)
local qs = wsapi_env.QUERY_STRING
print("QUERY_STRING: " .. qs)

local req = ws_request.new(wsapi_env)

return 200, {}, coroutine.wrap(function()
coroutine.yield(tostring(req.params.key1) .. tostring(req.params.key2))
end)
end

local app = mock.make_handler(test_app)

local response, request = app:get("test", { key1="1", key2="2"})
assert(response.code == 200)
assert(response.body == "12")
~~~~

I could fix that in _wsapi.mock_, just stripping the question mark, but it seems wrong to me.
If _wsapi.request.qs_encode_ does not include it, methods like _request.route_link_ and _request.link_ should be fixed. That seems like the proper thing to do.
What do you think?