-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | HTTP server library
--
-- A simple but practical library of HTTP server
@package webserver
@version 0.4.6
-- | Parser for URI
module Network.Web.URI
-- | Abstract data type for URI
data URI
uriScheme :: URI -> ByteString
uriAuthority :: URI -> Maybe URIAuth
uriPath :: URI -> ByteString
uriQuery :: URI -> ByteString
uriFragment :: URI -> ByteString
-- | Abstract data type for URI Authority
data URIAuth
uriUserInfo :: URIAuth -> ByteString
uriRegName :: URIAuth -> ByteString
uriPort :: URIAuth -> ByteString
-- | Parsing URI.
parseURI :: ByteString -> Maybe URI
-- | Getting a hostname from URI.
uriHostName :: URI -> ByteString
-- | Getting a port number from URI.
uriPortNumber :: URI -> ByteString
-- | Making a URL string from URI.
toURL :: URI -> ByteString
-- | Making a URL string from URI without port.
toURLwoPort :: URI -> ByteString
-- | Making a URL string from URI without port and parameters.
toURLPath :: URI -> ByteString
-- | Checking whether or not URI starts with "http:".
isAbsoluteURI :: ByteString -> Bool
-- | Decoding the %XX encoding.
unEscapeString :: String -> String
-- | Decoding the %XX encoding.
unEscapeByteString :: ByteString -> ByteString
instance Show URIAuth
instance Show URI
-- | HTTP library for HTTP server.
module Network.Web.HTTP
-- | Receiving HTTP request from Handle. If request is broken,
-- Nothing is returned.
receive :: Handle -> IO (Maybe Request)
-- | Sending HTTP response to Handle. If Keep is specified,
-- the HTTP connection will be kept. If Close is specified, the
-- connection will be closed. Version should be copied from
-- Request.
respond :: Handle -> Version -> Persist -> Response -> IO ()
-- | Abstract data type of HTTP request.
data Request
-- | Request method
reqMethod :: Request -> Method
-- | URI parsed from absolute URL or relative URL with the Host: field
reqURI :: Request -> URI
-- | HTTP version
reqVersion :: Request -> Version
-- | Key-values of request header
reqFields :: Request -> Fields
-- | Entity body if exists
reqBody :: Request -> Maybe ByteString
-- | Length of entity body from Content-Length:
reqLength :: Request -> Integer
-- | Abstract data type of HTTP response.
data Response
-- | Response status
rspStatus :: Response -> Status
rspFields :: Response -> Fields
rspBody :: Response -> Maybe ByteString
rspLength :: Response -> Maybe Integer
rspLogMsg :: Response -> String
-- | A function to make Response.
makeResponse :: Status -> [(FieldKey, FieldValue)] -> Response
-- | A function to make Response.
makeResponse2 :: Status -> Maybe ByteString -> Maybe Integer -> [(FieldKey, FieldValue)] -> Response
-- | A function to make Response.
makeResponse3 :: Status -> Maybe ByteString -> Maybe Integer -> Fields -> Response
-- | A class to abstract Request and Response.
class Comm a
-- | Abstract data type for Key-values of HTTP header.
data Fields
-- | Looking up the HTTP field value.
lookupField :: Comm a => FieldKey -> a -> Maybe FieldValue
-- | Looking up the HTTP field value.
lookupField' :: FieldKey -> Fields -> Maybe FieldValue
-- | Inserting the HTTP field.
insertField :: Comm a => FieldKey -> FieldValue -> a -> a
-- | Inserting the HTTP field.
insertField' :: FieldKey -> FieldValue -> Fields -> Fields
-- | Parsing HTTP header from Handle. This function is useful to
-- parse CGI output.
receiveFields :: Handle -> IO Fields
-- | Methods of HTTP.
data Method
GET :: Method
HEAD :: Method
POST :: Method
PUT :: Method
DELETE :: Method
TRACE :: Method
CONNECT :: Method
UnknownMethod :: Method
toMethod :: ByteString -> Method
-- | Versions of HTTP.
data Version
HTTP10 :: Version
HTTP11 :: Version
toVersion :: ByteString -> Version
fromVersion :: Version -> ByteString
-- | Status of HTTP.
data Status
Continue :: Status
SwitchingProtocols :: Status
OK :: Status
Created :: Status
Accepted :: Status
NonAuthoritativeInformation :: Status
NoContent :: Status
ResetContent :: Status
PartialContent :: Integer -> Integer -> Status
MultipleChoices :: Status
MovedPermanently :: Status
Found :: Status
SeeOther :: Status
NotModified :: Status
UseProxy :: Status
TemporaryRedirect :: Status
BadRequest :: Status
Unauthorized :: Status
PaymentRequired :: Status
Forbidden :: Status
NotFound :: Status
MethodNotAllowed :: Status
NotAcceptable :: Status
ProxyAuthenticationRequired :: Status
RequestTimeout :: Status
Conflict :: Status
Gone :: Status
LengthRequired :: Status
PreconditionFailed :: Status
RequestEntityTooLarge :: Status
RequestURITooLarge :: Status
UnsupportedMediaType :: Status
RequestedRangeNotSatisfiable :: Status
ExpectationFailed :: Status
InternalServerError :: Status
NotImplemented :: Status
BadGateway :: Status
ServiceUnavailable :: Status
GatewayTimeout :: Status
HTTPVersionNotSupported :: Status
-- | Converting numeric status to Status.
toStatus :: ByteString -> Maybe Status
fromStatus :: Status -> ByteString
-- | Returning True for 4xx and 5xx.
badStatus :: Status -> Bool
-- | The type for persist connection or not
data Persist
Close :: Persist
Keep :: Persist
PerUnknown :: Persist
toPersist :: ByteString -> Persist
fromPersist :: Persist -> ByteString
-- | Exceptions for Web server
data ServerException
TimeOut :: ServerException
TerminatedByClient :: ServerException
-- | Field key of HTTP header.
data FieldKey
FkAcceptLanguage :: FieldKey
FkCacheControl :: FieldKey
FkConnection :: FieldKey
FkContentLength :: FieldKey
FkContentType :: FieldKey
FkCookie :: FieldKey
FkDate :: FieldKey
FkHost :: FieldKey
FkIfModifiedSince :: FieldKey
FkIfRange :: FieldKey
FkIfUnmodifiedSince :: FieldKey
FkLastModified :: FieldKey
FkLocation :: FieldKey
FkRange :: FieldKey
FkServer :: FieldKey
FkSetCookie2 :: FieldKey
FkStatus :: FieldKey
FkTransferEncoding :: FieldKey
FkOther :: ByteString -> FieldKey
-- | Field value of HTTP header.
type FieldValue = ByteString
-- | Converting field key to FieldKey.
toFieldKey :: ByteString -> FieldKey
-- | Converting FieldKey to field key.
fromFieldKey :: FieldKey -> ByteString
-- | The type for Content-Type.
type CT = ByteString
-- | The value for text/html.
textHtml :: CT
-- | Selecting a value of Content-Type from a file suffix.
selectContentType :: String -> CT
instance Show Fields
instance Show Request
instance Comm Response
instance Comm Request
-- | HTTP server library.
module Network.Web.Server
-- | A function to run an WebServer. Handle should be mode by
-- converting an accepted socket. Keep-alive / termination of HTTP 1.0
-- and HTTP 1.1 is correctly handled. So, WebServer need not to
-- handle the Connection: header in response. The Date: header is
-- automatically added in response.
connection :: Handle -> WebServer -> WebConfig -> IO ()
-- | The type for HTTP server.
type WebServer = Maybe Request -> IO Response
-- | The configuration for connection.
data WebConfig
WebConfig :: (String -> IO ()) -> (String -> IO ()) -> (String -> IO ()) -> (String -> IO ()) -> Int -> WebConfig
-- | A hook to be called when an HTTP connection is closed.
closedHook :: WebConfig -> String -> IO ()
-- | A hook to be called when access succeeds.
accessHook :: WebConfig -> String -> IO ()
-- | A hook to be called when an access error occurs.
errorHook :: WebConfig -> String -> IO ()
-- | A hook to be called when a fatal error occurs.
fatalErrorHook :: WebConfig -> String -> IO ()
-- | A time to unblock receiving an HTTP request in seconds.
connectionTimer :: WebConfig -> Int
-- | Creating basic WebServer. Created WebServer can handle
-- GET / HEAD / POST; OK, Not Found, Not Modified, Moved Permanently,
-- etc; partial getting; language negotication; CGI, chunked data for CGI
-- output;
module Network.Web.Server.Basic
-- | Creating WebServer with BasicConfig. The created
-- WebServer can handle GET / HEAD / POST; OK, Not Found, Not
-- Modified, Moved Permanently, etc; partial getting; language
-- negotication; CGI, chunked data for CGI output; If
-- http://example.com/path does not exist but http://example.com/path/
-- exists, the created WebServer redirects it.
-- http://example.com/path/ is mapped to /somewhere/path/ by
-- mapper and index.html and index.html.en automatically added and
-- try to read by obtain. If Accept-Language is xx and
-- yy in order, index.html.xx, index.html.yy, index.html and
-- index.html.en are tried. The created WebServer does not
-- dynamically make index.html for a directory even if index.html does
-- not exist for security reasons.
basicServer :: BasicConfig -> WebServer
-- | The configuration for the basic web server.
data BasicConfig
BasicConfig :: (URI -> Path) -> (FilePath -> Maybe (Integer, Integer) -> IO ByteString) -> (FilePath -> IO (Maybe (Integer, UTCTime))) -> ByteString -> TCPInfo -> BasicConfig
-- | A mapper from URI to Path.
mapper :: BasicConfig -> URI -> Path
-- | Resource obtaining function. The second argument is (offset of the
-- resource, and length from the offset).
obtain :: BasicConfig -> FilePath -> Maybe (Integer, Integer) -> IO ByteString
-- | A function to return the size of the resource and its modification
-- time if exists.
info :: BasicConfig -> FilePath -> IO (Maybe (Integer, UTCTime))
-- | A server name specified the Server: field.
serverName :: BasicConfig -> ByteString
-- | TCPInfo for passing CGI. (See c10k library.)
tcpInfo :: BasicConfig -> TCPInfo
-- | Control information of how to handle URI.
data Path
-- | URI cannot be converted into any resources.
None :: Path
-- | URI is converted into a resource (typically a file).
File :: FilePath -> Path
-- | URI is converted into CGI.
PathCGI :: CGI -> Path
-- | Internal information of CGI converted from URI.
data CGI
CGI :: FilePath -> String -> String -> String -> CGI
-- | A porgram path to be executed.
progPath :: CGI -> FilePath
-- | A script name.
scriptName :: CGI -> String
-- | A path information.
pathInfo :: CGI -> String
-- | A query string.
queryString :: CGI -> String