http-server 1.0.2 → 1.0.3
raw patch · 3 files changed
+127/−35 lines, 3 filesdep ~network
Dependency ranges changed: network
Files
- Network/HTTP/Server.hs +3/−2
- Network/HTTP/Server/Response.hs +122/−31
- http-server.cabal +2/−2
Network/HTTP/Server.hs view
@@ -31,8 +31,9 @@ #endif import Network.Socket (Socket,socket,withSocketsDo,SocketType(..),SocketOption(..)- ,setSocketOption,SockAddr(..),listen,bindSocket,sClose,accept+ ,setSocketOption,SockAddr(..),listen,bindSocket,accept ,sOMAXCONN)+import qualified Network.Socket as Socket (close) import Network.BSD import Network.HTTP import Network.HTTP.Headers -- for re-export above@@ -105,7 +106,7 @@ do s <- server_init conf loop s `catch` \e -> logError lg ("Unexpected (0): " ++ show (e :: SomeException))- sClose s+ Socket.close s where lg = srvLog conf
Network/HTTP/Server/Response.hs view
@@ -11,22 +11,51 @@ module Network.HTTP.Server.Response where -import Network.HTTP+import Network.HTTP hiding (Continue) import Network.BufferType --- | A list of status code. This not yet complete.+-- | HTTP/1.1 status codes data StatusCode- = OK- | SeeOther- | BadRequest- | Forbidden- | NotFound- | Found- | Conflict- | InternalServerError- | NotImplemented--+ = Continue -- ^ 100+ | SwitchingProtocols -- ^ 101+ | OK -- ^ 200+ | Created -- ^ 201+ | Accepted -- ^ 202+ | NonAuthoritativeInformation -- ^ 203 + | NoContent -- ^ 204+ | ResetContent -- ^ 205+ | PartialContent -- ^ 206+ | MultipleChoices -- ^ 300+ | MovedPermanently -- ^ 301+ | Found -- ^ 302+ | SeeOther -- ^ 303+ | NotModified -- ^ 304+ | UseProxy -- ^ 305+ | TemporaryRedirect -- ^ 307+ | BadRequest -- ^ 400+ | Unauthorized -- 401+ | PaymentRequired -- ^ 402+ | Forbidden -- ^ 403+ | NotFound -- ^ 404+ | MethodNotAllowed -- ^ 405+ | NotAcceptable -- ^ 406+ | ProxyAuthenticationRequired -- ^ 407+ | RequestTimeout -- ^ 408+ | Conflict -- ^ 409+ | Gone -- ^ 410+ | LengthRequired -- ^ 411+ | PreconditionFailed -- ^ 412+ | RequestEntityTooLarge -- ^ 413+ | RequestURITooLong -- ^ 414+ | UnsupportedMediaType -- ^ 415+ | RequestedRangeNotSatisfiable -- ^ 416+ | ExpectationFailed -- ^ 417+ | InternalServerError -- ^ 500+ | NotImplemented -- ^ 501+ | BadGateway -- ^ 502+ | ServiceUnavailable -- ^ 503+ | GatewayTimeout -- ^ 504+ | HTTPVersionNotSupported -- ^ 505 -- | Make a simple response with the given status and body. -- Intended to be used for (bad) errors.@@ -47,24 +76,86 @@ -- | A brief description of what happend. reason :: StatusCode -> String reason code = case code of- OK -> "OK"- SeeOther -> "See other"- BadRequest -> "Bad request"- Conflict -> "Conflict"- Forbidden -> "Forbidden"- NotFound -> "Not found"- Found -> "Found"- InternalServerError -> "Internal server error"- NotImplemented -> "Not implemented"+ Continue -> "Continue"+ SwitchingProtocols -> "Switching protocols"+ OK -> "OK"+ Created -> "Created"+ Accepted -> "Accepted"+ NonAuthoritativeInformation -> "Non authoritative information"+ NoContent -> "No content"+ ResetContent -> "Reset content"+ PartialContent -> "Partial content"+ MultipleChoices -> "Multiple choices"+ MovedPermanently -> "Moved permanently"+ Found -> "Found"+ SeeOther -> "See other"+ NotModified -> "Not modified"+ UseProxy -> "Use proxy"+ TemporaryRedirect -> "Temporary redirect"+ BadRequest -> "Bad request"+ Unauthorized -> "Unauthorized"+ PaymentRequired -> "Payment required"+ Forbidden -> "Forbidden"+ NotFound -> "Not found"+ MethodNotAllowed -> "Method not allowed"+ NotAcceptable -> "Not acceptable"+ ProxyAuthenticationRequired -> "Proxy authentication required"+ RequestTimeout -> "Request timeout"+ Conflict -> "Conflict"+ Gone -> "Gone"+ LengthRequired -> "Length required"+ PreconditionFailed -> "Precondition failed"+ RequestEntityTooLarge -> "Request entity too large"+ RequestURITooLong -> "Request URI too long"+ UnsupportedMediaType -> "Unsupported media type"+ RequestedRangeNotSatisfiable -> "Requested range not satisfiable"+ ExpectationFailed -> "Expectation failed"+ InternalServerError -> "Internal server error"+ NotImplemented -> "Not implemented"+ BadGateway -> "Bad gateweay"+ ServiceUnavailable -> "Service unavailable"+ GatewayTimeout -> "Gateway timeout"+ HTTPVersionNotSupported -> "HTTP version not supported" statusCodeTriplet :: StatusCode -> (Int,Int,Int) statusCodeTriplet x = case x of- OK -> (2,0,0)- Found -> (3,0,2)- SeeOther -> (3,0,3)- BadRequest -> (4,0,0)- Forbidden -> (4,0,3)- NotFound -> (4,0,4)- Conflict -> (4,0,9)- InternalServerError -> (5,0,0)- NotImplemented -> (5,0,1)+ Continue -> (1,0,0)+ SwitchingProtocols -> (1,0,1)+ OK -> (2,0,0)+ Created -> (2,0,1)+ Accepted -> (2,0,2)+ NonAuthoritativeInformation -> (2,0,3) + NoContent -> (2,0,4)+ ResetContent -> (2,0,5)+ PartialContent -> (2,0,6)+ MultipleChoices -> (3,0,0)+ MovedPermanently -> (3,0,1)+ Found -> (3,0,2)+ SeeOther -> (3,0,3)+ NotModified -> (3,0,4)+ UseProxy -> (3,0,5)+ TemporaryRedirect -> (3,0,7)+ BadRequest -> (4,0,0)+ Unauthorized -> (4,0,1)+ PaymentRequired -> (4,0,2)+ Forbidden -> (4,0,3)+ NotFound -> (4,0,4)+ MethodNotAllowed -> (4,0,5)+ NotAcceptable -> (4,0,6)+ ProxyAuthenticationRequired -> (4,0,7)+ RequestTimeout -> (4,0,8)+ Conflict -> (4,0,9)+ Gone -> (4,1,0)+ LengthRequired -> (4,1,1)+ PreconditionFailed -> (4,1,2) + RequestEntityTooLarge -> (4,1,3)+ RequestURITooLong -> (4,1,4)+ UnsupportedMediaType -> (4,1,5)+ RequestedRangeNotSatisfiable -> (4,1,6)+ ExpectationFailed -> (4,1,7)+ InternalServerError -> (5,0,0)+ NotImplemented -> (5,0,1)+ BadGateway -> (5,0,2)+ ServiceUnavailable -> (5,0,3)+ GatewayTimeout -> (5,0,4)+ HTTPVersionNotSupported -> (5,0,5)
http-server.cabal view
@@ -1,5 +1,5 @@ name: http-server-version: 1.0.2+version: 1.0.3 category: Network synopsis: A library for writing Haskell web servers. description: A library for writing Haskell web servers.@@ -34,7 +34,7 @@ HTTP >= 4000.2.0 && < 5000, base >= 4 && < 5, mime >= 0.3 && < 2,- network >= 2 && < 3,+ network >= 2.4.0.0 && < 3, url >= 2 && < 3, utf8-string >= 0.3.4 && < 2