From 83afdcb96ba6a6937c5ae4ac8ed4e87621156c0f Mon Sep 17 00:00:00 2001 From: Daniel Larsson Date: Thu, 1 Jan 2015 15:14:07 +0100 Subject: [PATCH] Declared query string parameters are always sent in requests, even when no value is assigned to them (?name). The server handles a missing query parameter, and a query parameter with no value the same, but to be consistent with the documentation ("If you give Nothing, nothing will be added to the query string.") I made a small change to avoid sending empty query parameters. Also the value and req' parameters were flipped in the lambda in the QueryParams case. --- src/Servant/Client.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Servant/Client.hs b/src/Servant/Client.hs index ed63de47..117a03f8 100644 --- a/src/Servant/Client.hs +++ b/src/Servant/Client.hs @@ -210,7 +210,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout) -- if mparam = Nothing, we don't add it to the query string clientWithRoute Proxy req mparam = clientWithRoute (Proxy :: Proxy sublayout) $ - appendToQueryString pname mparamText req + maybe req (flip (appendToQueryString pname) req . Just) mparamText where pname = cs pname' pname' = symbolVal (Proxy :: Proxy sym) @@ -251,7 +251,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout) clientWithRoute Proxy req paramlist = clientWithRoute (Proxy :: Proxy sublayout) $ - foldl' (\ value req' -> appendToQueryString pname req' value) req paramlist' + foldl' (\ req' -> maybe req' (flip (appendToQueryString pname) req' . Just)) req paramlist' where pname = cs pname' pname' = symbolVal (Proxy :: Proxy sym)