getParams only gets the first parameter #134

shawjef3 opened this Issue May 11, 2012 · 5 comments


None yet
2 participants

rqQueryString doesn't contain any part of the query string after the first '&'. Whatever causes this also seems to be causing getParams to only ever contain one element.


ghost commented May 12, 2012

This might be an issue with my custom attoparsec. I'll test and report back.


gregorycollins commented May 12, 2012

Not reproducible:

{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as S
import           Snap.Core
import           Snap.Util.FileServe
import           Snap.Http.Server

main :: IO ()
main = quickHttpServe site

site :: Snap ()
site = do
    params <- liftM (S.pack . show) getParams
    qstr   <- liftM rqQueryString getRequest
    writeBS $ S.concat [
                  "params is:\n"
                , params
                , "\n\n\nquery string is:\n"
                , qstr
                , "\n"


$ curl 'http://localhost:8000/?foo=bar&foo=baz&baz=quux'
params is:
fromList [("baz",["quux"]),("foo",["bar","baz"])]

query string is:

This is bizarre. I reinstalled attoparsec and the snap packages, and the your code yields

params is:
fromList [("foo",["bar"])]

query string is:


gregorycollins commented May 14, 2012

Dumb question: how are you making the request? Are you using curl on the command line? If so, are you quoting the url properly?

I'm sure this was due to me forgetting that I modified attoparsec. It's fine now that I recompiled from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment