Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bugfix, don't use REQUEST_URI

  • Loading branch information...
commit a4ed3ba9689ef60012634951dfbbe171814de840 1 parent 85993f6
Eelco Lempsink eelco authored
Showing with 16 additions and 12 deletions.
  1. +1 −1  happstack-fastcgi.cabal
  2. +15 −11 src/Happstack/Server/FastCGI.hs
2  happstack-fastcgi.cabal
View
@@ -1,5 +1,5 @@
Name: happstack-fastcgi
-Version: 0.1.1
+Version: 0.1.2
Copyright: Tupil
Maintainer: ce [at] tupil.com, eml [at] tupil.com
License: BSD3
26 src/Happstack/Server/FastCGI.hs
View
@@ -81,8 +81,12 @@ withDef x = maybe x id
-- | Look up a String in the cgiVars, returning the empty string if the key is not present
str k v = withDef "" (v ? k)
+-- | Append if the list is not empty
+x ?: [] = []
+x ?: xs = x : xs
+
cgiUri :: CGIRequest -> String
-cgiUri = str "REQUEST_URI"
+cgiUri x = str "PATH_INFO" x ++ cgiQuery x
cgiMethod :: CGIRequest -> Method
cgiMethod x = withDef GET $ (x ? "HTTP_METHOD") >>= maybeRead
@@ -91,29 +95,29 @@ cgiPaths :: CGIRequest -> [String]
cgiPaths = split '/' . str "PATH_INFO"
cgiQuery :: CGIRequest -> String
-cgiQuery x = '?':(str "QUERY_STRING" x)
+cgiQuery x = '?' ?: (str "QUERY_STRING" x)
cgiInputs :: CGI [(String, Input)]
cgiInputs = getInputNames >>= mapM toHappstackInput
cgiCookies :: CGIRequest -> [(String, H.Cookie)]
-cgiCookies = map cookieWithName . either (const []) id . parseCookies . str "HTTP_COOKIE"
+cgiCookies = map cookieWithName . either (const []) id . parseCookies . str "HTTP_COOKIE"
cgiVersion :: CGIRequest -> Version
-cgiVersion = parseProtocol . str "SERVER_PROTOCOL"
+cgiVersion = parseProtocol . str "SERVER_PROTOCOL"
cgiHeaders :: CGIRequest -> Headers
-cgiHeaders = mkHeaders
- . mapKeys (replace '_' '-' . drop (length httpPrefix))
- . filterKey (isPrefixOf httpPrefix)
- . M.toList
- . cgiVars
+cgiHeaders = mkHeaders
+ . mapKeys (replace '_' '-' . drop (length httpPrefix))
+ . filterKey (isPrefixOf httpPrefix)
+ . M.toList
+ . cgiVars
cgiBody :: CGIRequest -> RqBody
-cgiBody = Body . cgiRequestBody
+cgiBody = Body . cgiRequestBody
cgiPeer :: CGIRequest -> (String, Int)
-cgiPeer r = (str "REMOTE_ADDR" r, withDef 0 (r ? "REMOTE_PORT" >>= maybeRead)) -- TODO
+cgiPeer r = (str "REMOTE_ADDR" r, withDef 0 (r ? "REMOTE_PORT" >>= maybeRead)) -- TODO
-- | Replace x by y in a map
Please sign in to comment.
Something went wrong with that request. Please try again.