-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for writing Haskell web servers. -- -- A library for writing Haskell web servers. @package http-server @version 1.0.5 module Network.HTTP.Server.HtmlForm -- | An abstraction of a map mapping form fields to their values. data FormFields -- | The names of the fields that were posted. fieldNames :: FormFields -> [String] -- | Do we have the given field? hasField :: FormFields -> String -> Bool -- | Lookup a field value as a string. lookupString :: FormFields -> String -> Maybe String -- | Lookup a field value and try to parse it. lookupRead :: Read a => FormFields -> String -> Maybe a -- | The fields as pairs of strings. toList :: FormFields -> [(String, String)] -- | Try to parse the body of a request. fromRequest :: Request String -> Maybe FormFields instance Show FormFields module Network.HTTP.Server.Logger -- | A type used by the server to report various events. Useful for -- debugging. data Logger Logger :: (Int -> String -> IO ()) -> (String -> IO ()) -> (String -> IO ()) -> (String -> IO ()) -> (Maybe Int -> (LogType -> Bool) -> IO [LogItem]) -> Logger logInfo :: Logger -> Int -> String -> IO () logDebug :: Logger -> String -> IO () logError :: Logger -> String -> IO () logWarning :: Logger -> String -> IO () getLog :: Logger -> Maybe Int -> (LogType -> Bool) -> IO [LogItem] -- | A logger that uses the standard output and standard error. Text is -- UTF8 encoded. stdLogger :: Logger -- | A logger that does not report anything. quietLogger :: Logger -- | A logger that uses the given handles for output and errors. utf8Logger :: Handle -> Handle -> Logger data LogItem LogItem :: LogType -> String -> LogItem item_type :: LogItem -> LogType item_data :: LogItem -> String data LogType Error :: LogType Warning :: LogType Debug :: LogType Info :: Int -> LogType showLogItem :: LogItem -> String readLogItem :: String -> Maybe LogItem filterLog :: Maybe Int -> (LogType -> Bool) -> [LogItem] -> [LogItem] instance Show LogType module Network.HTTP.Server.Response -- | HTTP/1.1 status codes data StatusCode -- | 100 Continue :: StatusCode -- | 101 SwitchingProtocols :: StatusCode -- | 200 OK :: StatusCode -- | 201 Created :: StatusCode -- | 202 Accepted :: StatusCode -- | 203 NonAuthoritativeInformation :: StatusCode -- | 204 NoContent :: StatusCode -- | 205 ResetContent :: StatusCode -- | 206 PartialContent :: StatusCode -- | 300 MultipleChoices :: StatusCode -- | 301 MovedPermanently :: StatusCode -- | 302 Found :: StatusCode -- | 303 SeeOther :: StatusCode -- | 304 NotModified :: StatusCode -- | 305 UseProxy :: StatusCode -- | 307 TemporaryRedirect :: StatusCode -- | 400 BadRequest :: StatusCode Unauthorized :: StatusCode -- | 402 PaymentRequired :: StatusCode -- | 403 Forbidden :: StatusCode -- | 404 NotFound :: StatusCode -- | 405 MethodNotAllowed :: StatusCode -- | 406 NotAcceptable :: StatusCode -- | 407 ProxyAuthenticationRequired :: StatusCode -- | 408 RequestTimeout :: StatusCode -- | 409 Conflict :: StatusCode -- | 410 Gone :: StatusCode -- | 411 LengthRequired :: StatusCode -- | 412 PreconditionFailed :: StatusCode -- | 413 RequestEntityTooLarge :: StatusCode -- | 414 RequestURITooLong :: StatusCode -- | 415 UnsupportedMediaType :: StatusCode -- | 416 RequestedRangeNotSatisfiable :: StatusCode -- | 417 ExpectationFailed :: StatusCode -- | 500 InternalServerError :: StatusCode -- | 501 NotImplemented :: StatusCode -- | 502 BadGateway :: StatusCode -- | 503 ServiceUnavailable :: StatusCode -- | 504 GatewayTimeout :: StatusCode -- | 505 HTTPVersionNotSupported :: StatusCode -- | Make a simple response with the given status and body. Intended to be -- used for (bad) errors. Adds a "close" header. err_response :: BufferType a => StatusCode -> Response a -- | Make a simple response with the given status and body. No headers or -- body. respond :: BufferType a => StatusCode -> Response a -- | A brief description of what happend. reason :: StatusCode -> String statusCodeTriplet :: StatusCode -> (Int, Int, Int) module Network.HTTP.Server -- | Start a server with the default configuration, and the given handler. -- Requests are handled in separate threads. server :: HStream a => Handler a -> IO () -- | Start a server with the given configuration and handler. Requests are -- handled in separate threads. serverWith :: HStream a => Config -> Handler a -> IO () -- | Handlers invoked to process requests. The type parameter is for the -- type of the payload in the body. It is a variation on string of some -- sort (e.g., String, ByteString, etc.) type Handler a = SockAddr -> URL -> Request a -> IO (Response a) -- | Server configuration. data Config Config :: Logger -> HostName -> PortNumber -> Config -- | Server reports what's going on here. srvLog :: Config -> Logger -- | Host name to bind to. srvHost :: Config -> HostName -- | Port to listen on. srvPort :: Config -> PortNumber -- | Some default options for a server: no logging output, listen on -- "localhost:8000". defaultConfig :: Config -- | An HTTP Request. The Show instance of this type is used for -- message serialisation, which means no body data is output. data Request a :: * -> * Request :: URI -> RequestMethod -> [Header] -> a -> Request a -- | might need changing in future 1) to support * uri in OPTIONS -- request 2) transparent support for both relative & absolute uris, -- although this should already work (leave scheme & host parts -- empty). rqURI :: Request a -> URI rqMethod :: Request a -> RequestMethod rqHeaders :: Request a -> [Header] rqBody :: Request a -> a -- | An HTTP Response. The Show instance of this type is used for -- message serialisation, which means no body data is output, -- additionally the output will show an HTTP version of 1.1 instead of -- the actual version returned by a server. data Response a :: * -> * Response :: ResponseCode -> String -> [Header] -> a -> Response a rspCode :: Response a -> ResponseCode rspReason :: Response a -> String rspHeaders :: Response a -> [Header] rspBody :: Response a -> a -- | The HTTP request method, to be used in the Request object. We -- are missing a few of the stranger methods, but these are not really -- necessary until we add full TLS. data RequestMethod :: * HEAD :: RequestMethod PUT :: RequestMethod GET :: RequestMethod POST :: RequestMethod DELETE :: RequestMethod OPTIONS :: RequestMethod TRACE :: RequestMethod CONNECT :: RequestMethod Custom :: String -> RequestMethod