wai-extra-3.0.29.1: Provides some basic WAI handlers and middleware.

Safe HaskellNone
LanguageHaskell2010

Network.Wai.Parse

Description

Some helpers for parsing data out of a raw WAI Request.

Synopsis

Documentation

parseHttpAccept :: ByteString -> [ByteString] Source #

Parse the HTTP accept string to determine supported content types.

parseRequestBody :: BackEnd y -> Request -> IO ([Param], [File y]) Source #

Parse the body of an HTTP request. See parseRequestBodyEx for details. Note: This function does not limit the memory it allocates. When dealing with untrusted data (as is usually the case when receiving input from the internet), it is recommended to use the parseRequestBodyEx function instead.

data RequestBodyType Source #

The mimetype of the http body. Depending on whether just parameters or parameters and files are passed, one or the other mimetype should be used.

Constructors

UrlEncoded

application/x-www-form-urlencoded (parameters only)

Multipart ByteString

multipart/form-data (parameters and files)

getRequestBodyType :: Request -> Maybe RequestBodyType Source #

Get the mimetype of the body of an http request.

type BackEnd a Source #

Arguments

 = ByteString

parameter name

-> FileInfo () 
-> IO ByteString 
-> IO a 

A file uploading backend. Takes the parameter name, file name, and a stream of data.

lbsBackEnd :: Monad m => ignored1 -> ignored2 -> m ByteString -> m ByteString Source #

Store uploaded files in memory

tempFileBackEnd :: InternalState -> ignored1 -> ignored2 -> IO ByteString -> IO FilePath Source #

Save uploaded files on disk as temporary files

Note: starting with version 2.0, removal of temp files is registered with the provided InternalState. It is the responsibility of the caller to ensure that this InternalState gets cleaned up.

tempFileBackEndOpts Source #

Arguments

:: IO FilePath

get temporary directory

-> String

filename pattern

-> InternalState 
-> ignored1 
-> ignored2 
-> IO ByteString 
-> IO FilePath 

Same as tempFileBackEnd, but use configurable temp folders and patterns.

type Param = (ByteString, ByteString) Source #

Post parameter name and value.

type File y = (ByteString, FileInfo y) Source #

Post parameter name and associated file information.

data FileInfo c Source #

Information on an uploaded file.

Instances
Eq c => Eq (FileInfo c) Source # 
Instance details

Defined in Network.Wai.Parse

Methods

(==) :: FileInfo c -> FileInfo c -> Bool #

(/=) :: FileInfo c -> FileInfo c -> Bool #

Show c => Show (FileInfo c) Source # 
Instance details

Defined in Network.Wai.Parse

Methods

showsPrec :: Int -> FileInfo c -> ShowS #

show :: FileInfo c -> String #

showList :: [FileInfo c] -> ShowS #

parseContentType :: ByteString -> (ByteString, [(ByteString, ByteString)]) Source #

Parse a content type value, turning a single ByteString into the actual content type and a list of pairs of attributes.

Since: 1.3.2

data ParseRequestBodyOptions Source #

A data structure that describes the behavior of the parseRequestBodyEx function.

Since: 3.0.16.0

defaultParseRequestBodyOptions :: ParseRequestBodyOptions Source #

A reasonable default set of parsing options. Maximum key/filename length: 32 bytes; maximum files: 10; filesize unlimited; maximum size for parameters: 64kbytes; maximum number of header lines: 32 bytes (applies only to headers of a mime/multipart message); maximum header line length: Apache's default for that is 8190 bytes (http:/httpd.apache.orgdocs2.2mod/core.html#limitrequestline) so we're using that here as well.

Since: 3.0.16.0

noLimitParseRequestBodyOptions :: ParseRequestBodyOptions Source #

Do not impose any memory limits.

Since: 3.0.21.0

parseRequestBodyEx :: ParseRequestBodyOptions -> BackEnd y -> Request -> IO ([Param], [File y]) Source #

Parse the body of an HTTP request, limit resource usage. The HTTP body can contain both parameters and files. This function will return a list of key,value pairs for all parameters, and a list of key,a pairs for filenames. The a depends on the used backend that is responsible for storing the received files.

setMaxRequestKeyLength :: Int -> ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Set the maximum length of a filename.

Since: 3.0.16.0

clearMaxRequestKeyLength :: ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Do not limit the length of filenames.

Since: 3.0.16.0

setMaxRequestNumFiles :: Int -> ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Set the maximum number of files per request.

Since: 3.0.16.0

clearMaxRequestNumFiles :: ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Do not limit the maximum number of files per request.

Since: 3.0.16.0

setMaxRequestFileSize :: Int64 -> ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Set the maximum filesize per file (in bytes).

Since: 3.0.16.0

clearMaxRequestFileSize :: ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Do not limit the maximum filesize per file.

Since: 3.0.16.0

setMaxRequestFilesSize :: Int64 -> ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Set the maximum size of all files per request.

Since: 3.0.16.0

clearMaxRequestFilesSize :: ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Do not limit the maximum size of all files per request.

Since: 3.0.16.0

setMaxRequestParmsSize :: Int -> ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Set the maximum size of the sum of all parameters.

Since: 3.0.16.0

clearMaxRequestParmsSize :: ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Do not limit the maximum size of the sum of all parameters.

Since: 3.0.16.0

setMaxHeaderLines :: Int -> ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Set the maximum header lines per mime/multipart entry.

Since: 3.0.16.0

clearMaxHeaderLines :: ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Do not limit the maximum header lines per mime/multipart entry.

Since: 3.0.16.0

setMaxHeaderLineLength :: Int -> ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Set the maximum header line length per mime/multipart entry.

Since: 3.0.16.0

clearMaxHeaderLineLength :: ParseRequestBodyOptions -> ParseRequestBodyOptions Source #

Do not limit the maximum header lines per mime/multipart entry.

Since: 3.0.16.0