EllaSource codeContentsIndex
Ella.Request
Contents
Requests
Accessors of Request
Constructors for Request
Escaping
Encodings
Files
Synopsis
data Request
data RequestOptions = RequestOptions {
encoding :: Encoding
}
requestMethod :: Request -> String
pathInfo :: Request -> String
requestUriRaw :: Request -> Maybe String
environment :: Request -> Map String String
allPOST :: Request -> [(String, String)]
allGET :: Request -> [(String, String)]
getPOST :: Request -> String -> Maybe String
getPOSTlist :: Request -> String -> [String]
hasPOST :: Request -> String -> Bool
getGET :: Request -> String -> Maybe String
getGETlist :: Request -> String -> [String]
hasGET :: Request -> String -> Bool
getCookieVal
allCookies :: Request -> [(String, String)]
files :: Request -> Map String FileInput
mkRequest :: [(String, String)] -> ByteString -> Encoding -> Request
buildCGIRequest :: RequestOptions -> IO Request
changeEncoding :: Encoding -> Request -> Request
escapePath :: ByteString -> String
escapePathWithEnc :: String -> Encoding -> String
data Encoding = Encoding {
name :: String
decoder :: ByteString -> String
encoder :: String -> ByteString
}
utf8Encoding :: Encoding
data FileInput = FileInput {
fileFilename :: String
fileContents :: ByteString
fileContentType :: ContentType
}
data ContentType = ContentType {
ctType :: String
ctSubtype :: String
ctParameters :: [(String, String)]
}
Requests
data Request Source
Represents a CGI request. This contains the fundamental data that is passed around the CGI application. Accessor functions are provided to extract all the useful information.
show/hide Instances
data RequestOptions Source
Options that affect the way that HTTP requests are handled
Constructors
RequestOptions
encoding :: EncodingHandles request encoding translation
show/hide Instances
Accessors of Request
requestMethod :: Request -> StringSource
Returns the request method (GET, POST etc) of the request
pathInfo :: Request -> StringSource
Returns the path info of the request, with any leading forward slash removed, and percent encoded chars interpreted according to the encoding.
requestUriRaw :: Request -> Maybe StringSource

Returns the URI requested by the client, with percent encoding intact

This can fail if the environment does not pass REQUEST_URI. Apache always does pass this, so normally just use fromJust on the answer.

environment :: Request -> Map String StringSource
a map containing the CGI environment var
allPOST :: Request -> [(String, String)]Source
All of the POST name-value pairs. Use this if you need to iterate through POST variables
allGET :: Request -> [(String, String)]Source
All of the GET name-value pairs. Use this if you need to iterate through GET variables
getPOST :: Request -> String -> Maybe StringSource
Retrieve a single POST value
getPOSTlist :: Request -> String -> [String]Source

Retrieve all the POST values with the given name

This is needed if values are submitted with the same name e.g. for handling HTML SELECT elements

hasPOST :: Request -> String -> BoolSource
returns True if the specified key is found in the Request POST values
getGET :: Request -> String -> Maybe StringSource
Retrieve a single query string value (last one wins if there are multiple)
getGETlist :: Request -> String -> [String]Source

Retrieve all the query string values with the given name

This is needed if values are submitted with the same name

hasGET :: Request -> String -> BoolSource
returns True if the specified key is found in the Request query string paramaters
getCookieVal
allCookies :: Request -> [(String, String)]Source
files :: Request -> Map String FileInputSource
a map of all uploaded files
Constructors for Request
mkRequestSource
:: [(String, String)]association list of environment variables
-> ByteStringlazy ByteString containing request body
-> EncodingEncoding to use for request
-> Request
Create a Request object
buildCGIRequestSource
:: RequestOptionsoptions which determine how the HTTP request is interpreted
-> IO Request
Creates a Request object according to the CGI protocol
changeEncoding :: Encoding -> Request -> RequestSource

Change a Request's encoding

Reinterprets the data in a Request according to new encoding. It is not enough to just change the encoding value, as some data that depends on the encoding has already been created.

Escaping
escapePath :: ByteString -> StringSource
Escapes a string of bytes with percent encoding
escapePathWithEnc :: String -> Encoding -> StringSource
Escapes a unicode string with percent encoding, using the supplied bytestring/string Encoder
Encodings
data Encoding Source
Used to store conversion functions need to interpret CGI requests
Constructors
Encoding
name :: Stringdescriptive name of the encoding
decoder :: ByteString -> Stringconvert ByteString to unicode string
encoder :: String -> ByteStringconvert unicode string to ByteString
show/hide Instances
utf8Encoding :: EncodingSource
An Encoding for UTF8
Files
data FileInput Source
Represents an uploaded file
Constructors
FileInput
fileFilename :: Stringuser supplied filename for file
fileContents :: ByteStringraw contents of the file
fileContentType :: ContentTypeuser supplied content-type of the file
show/hide Instances
data ContentType Source
A MIME media type value. The Show instance is derived automatically. Use showContentType to obtain the standard string representation. See http://www.ietf.org/rfc/rfc2046.txt for more information about MIME media types.
Constructors
ContentType
ctType :: StringThe top-level media type, the general type of the data. Common examples are "text", "image", "audio", "video", "multipart", and "application".
ctSubtype :: StringThe media subtype, the specific data format. Examples include "plain", "html", "jpeg", "form-data", etc.
ctParameters :: [(String, String)]Media type parameters. On common example is the charset parameter for the "text" top-level type, e.g. ("charset","ISO-8859-1").
show/hide Instances
Produced by Haddock version 2.4.2