Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Multiple QueryParams aren't delimited with & #23

Closed
declension opened this issue Feb 24, 2017 · 3 comments
Closed

Multiple QueryParams aren't delimited with & #23

declension opened this issue Feb 24, 2017 · 3 comments

Comments

@declension
Copy link
Contributor

I may have misunderstood, so am quoting the test api / spec I used to narrow down the problem:

Test API

With this basic API:

type QueryStringAPI = "path" :> QueryParam "one" SafeText :> QueryParam "two" SafeText :> Get '[JSON] Text
qsApi:: Proxy QueryStringAPI
qsApi = Proxy

newtype SafeText = SafeText Text
instance ToHttpApiData SafeText
  where toUrlPiece (SafeText st) = st

Spec

..and a serverSatisifies spec like:

burl = BaseUrl Http "localhost" 8080 ""
spec = it "Query String API doesn't return 500" $
      serverSatisfies qsApi burl stdArgs
        (not500 <%> mempty)

instance Arbitrary SafeText
    -- Ensure it's not the random characters being the problem
    where arbitrary = return $ SafeText "value"

Output

Using a basic HTTP server (python -m SimpleHTTPServer 8080 here), I see lots of this in the logs:

127.0.0.1 - - [24/Feb/2017 18:01:06] "GET /path/?two=valueone=value HTTP/1.1" 404 -

Whilst I think the path/ is covered separately in #22, it's the missing & here that means I can't query the real API I was examining. Is this a bug?

Note: a client created with servant-client works as expected, with ampersands delimiting multiple (separate) QueryParams...

@declension
Copy link
Contributor Author

(for reference, from IRC): Line 95 (probably) needs to check whether the queryString is empty, and if it's not, use '&' before adding the param

declension added a commit to declension/servant-quickcheck that referenced this issue Mar 6, 2017
 * Add test API taking multiple `QueryParam`s
 * Add basic test using this API, generating an endpoint to ensure correct HTTP `one=foo&two=bar` query string generation is happening (that fails on `master`)
 * Fix (re)creation of query string to append `&` before the new parameter if there is already a built query string.

Fixes haskell-servant#23.
@declension
Copy link
Contributor Author

(Also realised this applies to QueryFlags)

declension added a commit to declension/servant-quickcheck that referenced this issue Mar 7, 2017
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
@jkarni
Copy link
Member

jkarni commented Mar 11, 2017

Released as 0.0.2.3

tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Add test API taking multiple `QueryParam`s
 * Add basic test using this API, generating an endpoint to ensure correct HTTP `one=foo&two=bar` query string generation is happening (that fails on `master`)
 * Fix (re)creation of query string to append `&` before the new parameter if there is already a built query string.

Fixes #23.
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Add test API taking multiple `QueryParam`s
 * Add basic test using this API, generating an endpoint to ensure correct HTTP `one=foo&two=bar` query string generation is happening (that fails on `master`)
 * Fix (re)creation of query string to append `&` before the new parameter if there is already a built query string.

Fixes #23.
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Add test API taking multiple `QueryParam`s
 * Add basic test using this API, generating an endpoint to ensure correct HTTP `one=foo&two=bar` query string generation is happening (that fails on `master`)
 * Fix (re)creation of query string to append `&` before the new parameter if there is already a built query string.

Fixes #23.
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Add test API taking multiple `QueryParam`s
 * Add basic test using this API, generating an endpoint to ensure correct HTTP `one=foo&two=bar` query string generation is happening (that fails on `master`)
 * Fix (re)creation of query string to append `&` before the new parameter if there is already a built query string.

Fixes #23.
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Add test API taking multiple `QueryParam`s
 * Add basic test using this API, generating an endpoint to ensure correct HTTP `one=foo&two=bar` query string generation is happening (that fails on `master`)
 * Fix (re)creation of query string to append `&` before the new parameter if there is already a built query string.

Fixes #23.
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Add test API taking multiple `QueryParam`s
 * Add basic test using this API, generating an endpoint to ensure correct HTTP `one=foo&two=bar` query string generation is happening (that fails on `master`)
 * Fix (re)creation of query string to append `&` before the new parameter if there is already a built query string.

Fixes #23.
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
tchoutri pushed a commit that referenced this issue Apr 22, 2024
 * Same logic / testing as for `QueryParam`
 * There's probably some de-duplication that could be done here one day...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants