http-types 0.8.6 → 0.9
raw patch · 6 files changed
+166/−86 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Network.HTTP.Types: httpMajor :: HttpVersion -> !Int
- Network.HTTP.Types: httpMinor :: HttpVersion -> !Int
- Network.HTTP.Types: statusCode :: Status -> Int
- Network.HTTP.Types: statusMessage :: Status -> ByteString
- Network.HTTP.Types.Header: instance Data ByteRange
- Network.HTTP.Types.Header: instance Eq ByteRange
- Network.HTTP.Types.Header: instance Ord ByteRange
- Network.HTTP.Types.Header: instance Show ByteRange
- Network.HTTP.Types.Header: instance Typeable ByteRange
- Network.HTTP.Types.Method: instance Bounded StdMethod
- Network.HTTP.Types.Method: instance Enum StdMethod
- Network.HTTP.Types.Method: instance Eq StdMethod
- Network.HTTP.Types.Method: instance Ix StdMethod
- Network.HTTP.Types.Method: instance Ord StdMethod
- Network.HTTP.Types.Method: instance Read StdMethod
- Network.HTTP.Types.Method: instance Show StdMethod
- Network.HTTP.Types.QueryLike: instance (QueryKeyLike k, QueryValueLike v) => QueryLike [(k, v)]
- Network.HTTP.Types.QueryLike: instance (QueryKeyLike k, QueryValueLike v) => QueryLike [Maybe (k, v)]
- Network.HTTP.Types.QueryLike: instance QueryKeyLike ByteString
- Network.HTTP.Types.QueryLike: instance QueryKeyLike Text
- Network.HTTP.Types.QueryLike: instance QueryKeyLike [Char]
- Network.HTTP.Types.QueryLike: instance QueryValueLike ByteString
- Network.HTTP.Types.QueryLike: instance QueryValueLike Text
- Network.HTTP.Types.QueryLike: instance QueryValueLike [Char]
- Network.HTTP.Types.QueryLike: instance QueryValueLike a => QueryValueLike (Maybe a)
- Network.HTTP.Types.Status: instance Enum Status
- Network.HTTP.Types.Status: instance Eq Status
- Network.HTTP.Types.Status: instance Ord Status
- Network.HTTP.Types.Status: instance Show Status
- Network.HTTP.Types.Status: statusCode :: Status -> Int
- Network.HTTP.Types.Status: statusMessage :: Status -> ByteString
- Network.HTTP.Types.Version: httpMajor :: HttpVersion -> !Int
- Network.HTTP.Types.Version: httpMinor :: HttpVersion -> !Int
- Network.HTTP.Types.Version: instance Eq HttpVersion
- Network.HTTP.Types.Version: instance Ord HttpVersion
- Network.HTTP.Types.Version: instance Show HttpVersion
+ Network.HTTP.Types: [httpMajor] :: HttpVersion -> !Int
+ Network.HTTP.Types: [httpMinor] :: HttpVersion -> !Int
+ Network.HTTP.Types: [statusCode] :: Status -> Int
+ Network.HTTP.Types: [statusMessage] :: Status -> ByteString
+ Network.HTTP.Types.Header: hAcceptCharset :: HeaderName
+ Network.HTTP.Types.Header: hAcceptEncoding :: HeaderName
+ Network.HTTP.Types.Header: hAcceptRanges :: HeaderName
+ Network.HTTP.Types.Header: hAge :: HeaderName
+ Network.HTTP.Types.Header: hAllow :: HeaderName
+ Network.HTTP.Types.Header: hContentLanguage :: HeaderName
+ Network.HTTP.Types.Header: hContentLocation :: HeaderName
+ Network.HTTP.Types.Header: hContentRange :: HeaderName
+ Network.HTTP.Types.Header: hETag :: HeaderName
+ Network.HTTP.Types.Header: hExpect :: HeaderName
+ Network.HTTP.Types.Header: hExpires :: HeaderName
+ Network.HTTP.Types.Header: hFrom :: HeaderName
+ Network.HTTP.Types.Header: hHost :: HeaderName
+ Network.HTTP.Types.Header: hIfMatch :: HeaderName
+ Network.HTTP.Types.Header: hIfNoneMatch :: HeaderName
+ Network.HTTP.Types.Header: hIfUnmodifiedSince :: HeaderName
+ Network.HTTP.Types.Header: hMaxForwards :: HeaderName
+ Network.HTTP.Types.Header: hPragma :: HeaderName
+ Network.HTTP.Types.Header: hProxyAuthenticate :: HeaderName
+ Network.HTTP.Types.Header: hProxyAuthorization :: HeaderName
+ Network.HTTP.Types.Header: hRetryAfter :: HeaderName
+ Network.HTTP.Types.Header: hTE :: HeaderName
+ Network.HTTP.Types.Header: hTrailer :: HeaderName
+ Network.HTTP.Types.Header: hTransferEncoding :: HeaderName
+ Network.HTTP.Types.Header: hUpgrade :: HeaderName
+ Network.HTTP.Types.Header: hVary :: HeaderName
+ Network.HTTP.Types.Header: hVia :: HeaderName
+ Network.HTTP.Types.Header: hWWWAuthenticate :: HeaderName
+ Network.HTTP.Types.Header: hWarning :: HeaderName
+ Network.HTTP.Types.Header: instance Data.Data.Data Network.HTTP.Types.Header.ByteRange
+ Network.HTTP.Types.Header: instance GHC.Classes.Eq Network.HTTP.Types.Header.ByteRange
+ Network.HTTP.Types.Header: instance GHC.Classes.Ord Network.HTTP.Types.Header.ByteRange
+ Network.HTTP.Types.Header: instance GHC.Show.Show Network.HTTP.Types.Header.ByteRange
+ Network.HTTP.Types.Method: instance GHC.Arr.Ix Network.HTTP.Types.Method.StdMethod
+ Network.HTTP.Types.Method: instance GHC.Classes.Eq Network.HTTP.Types.Method.StdMethod
+ Network.HTTP.Types.Method: instance GHC.Classes.Ord Network.HTTP.Types.Method.StdMethod
+ Network.HTTP.Types.Method: instance GHC.Enum.Bounded Network.HTTP.Types.Method.StdMethod
+ Network.HTTP.Types.Method: instance GHC.Enum.Enum Network.HTTP.Types.Method.StdMethod
+ Network.HTTP.Types.Method: instance GHC.Read.Read Network.HTTP.Types.Method.StdMethod
+ Network.HTTP.Types.Method: instance GHC.Show.Show Network.HTTP.Types.Method.StdMethod
+ Network.HTTP.Types.QueryLike: instance (Network.HTTP.Types.QueryLike.QueryKeyLike k, Network.HTTP.Types.QueryLike.QueryValueLike v) => Network.HTTP.Types.QueryLike.QueryLike [(k, v)]
+ Network.HTTP.Types.QueryLike: instance (Network.HTTP.Types.QueryLike.QueryKeyLike k, Network.HTTP.Types.QueryLike.QueryValueLike v) => Network.HTTP.Types.QueryLike.QueryLike [GHC.Base.Maybe (k, v)]
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryKeyLike Data.ByteString.Internal.ByteString
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryKeyLike Data.ByteString.Lazy.Internal.ByteString
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryKeyLike Data.Text.Internal.Text
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryKeyLike [GHC.Types.Char]
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryValueLike Data.ByteString.Internal.ByteString
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryValueLike Data.ByteString.Lazy.Internal.ByteString
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryValueLike Data.Text.Internal.Text
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryValueLike [GHC.Types.Char]
+ Network.HTTP.Types.QueryLike: instance Network.HTTP.Types.QueryLike.QueryValueLike a => Network.HTTP.Types.QueryLike.QueryValueLike (GHC.Base.Maybe a)
+ Network.HTTP.Types.Status: [statusCode] :: Status -> Int
+ Network.HTTP.Types.Status: [statusMessage] :: Status -> ByteString
+ Network.HTTP.Types.Status: instance GHC.Classes.Eq Network.HTTP.Types.Status.Status
+ Network.HTTP.Types.Status: instance GHC.Classes.Ord Network.HTTP.Types.Status.Status
+ Network.HTTP.Types.Status: instance GHC.Enum.Enum Network.HTTP.Types.Status.Status
+ Network.HTTP.Types.Status: instance GHC.Show.Show Network.HTTP.Types.Status.Status
+ Network.HTTP.Types.Status: permanentRedirect308 :: Status
+ Network.HTTP.Types.Status: status308 :: Status
+ Network.HTTP.Types.Version: [httpMajor] :: HttpVersion -> !Int
+ Network.HTTP.Types.Version: [httpMinor] :: HttpVersion -> !Int
+ Network.HTTP.Types.Version: instance GHC.Classes.Eq Network.HTTP.Types.Version.HttpVersion
+ Network.HTTP.Types.Version: instance GHC.Classes.Ord Network.HTTP.Types.Version.HttpVersion
+ Network.HTTP.Types.Version: instance GHC.Show.Show Network.HTTP.Types.Version.HttpVersion
Files
- Network/HTTP/Types/Header.hs +86/−25
- Network/HTTP/Types/Method.hs +3/−1
- Network/HTTP/Types/Status.hs +64/−52
- Network/HTTP/Types/URI.hs +4/−2
- Network/HTTP/Types/Version.hs +7/−4
- http-types.cabal +2/−2
Network/HTTP/Types/Header.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, DeriveDataTypeable #-}+{-# LANGUAGE OverloadedStrings, FlexibleInstances, MultiParamTypeClasses, DeriveDataTypeable, CPP #-} module Network.HTTP.Types.Header ( -- ** Types@@ -8,24 +8,53 @@ , ResponseHeaders -- ** Common headers , hAccept+, hAcceptCharset+, hAcceptEncoding , hAcceptLanguage+, hAcceptRanges+, hAge+, hAllow , hAuthorization , hCacheControl-, hCookie , hConnection , hContentEncoding+, hContentLanguage , hContentLength+, hContentLocation , hContentMD5+, hContentRange , hContentType+, hCookie , hDate+, hETag+, hExpect+, hExpires+, hFrom+, hHost+, hIfMatch , hIfModifiedSince+, hIfNoneMatch , hIfRange+, hIfUnmodifiedSince , hLastModified , hLocation+, hMaxForwards+, hPragma+, hProxyAuthenticate+, hProxyAuthorization , hRange , hReferer+, hRetryAfter , hServer+, hTE+, hTrailer+, hTransferEncoding+, hUpgrade , hUserAgent+, hVary+, hVia+, hWWWAuthenticate+, hWarning -- ** Byte ranges , ByteRange(..) , renderByteRangeBuilder@@ -37,7 +66,9 @@ where import Data.List+#if __GLASGOW_HASKELL__ < 710 import Data.Monoid+#endif import qualified Blaze.ByteString.Builder as Blaze import qualified Blaze.ByteString.Builder.Char8 as Blaze import qualified Data.ByteString as B@@ -59,31 +90,61 @@ type ResponseHeaders = [Header] -- | HTTP Header names-hAccept, hAcceptLanguage, hAuthorization, hCacheControl, hConnection, hContentEncoding, hContentLength, hContentMD5, hContentType, hCookie, hDate, hIfModifiedSince, hIfRange, hLastModified, hLocation, hRange, hReferer, hServer, hUserAgent :: HeaderName-hAccept = "Accept"-hAcceptLanguage = "Accept-Language"-hAuthorization = "Authorization"-hCacheControl = "Cache-Control"-hConnection = "Connection"-hContentEncoding = "Content-Encoding"-hContentLength = "Content-Length"-hContentMD5 = "Content-MD5"-hContentType = "Content-Type"-hCookie = "Cookie"-hDate = "Date"-hIfModifiedSince = "If-Modified-Since"-hIfRange = "If-Range"-hLastModified = "Last-Modified"-hLocation = "Location"-hRange = "Range"-hReferer = "Referer"-hServer = "Server"-hUserAgent = "User-Agent"+-- According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html+hAccept, hAcceptCharset, hAcceptEncoding, hAcceptLanguage, hAcceptRanges, hAge, hAllow, hAuthorization, hCacheControl, hConnection, hContentEncoding, hContentLanguage, hContentLength, hContentLocation, hContentMD5, hContentRange, hContentType, hCookie, hDate, hETag, hExpect, hExpires, hFrom, hHost, hIfMatch, hIfModifiedSince, hIfNoneMatch, hIfRange, hIfUnmodifiedSince, hLastModified, hLocation, hMaxForwards, hPragma, hProxyAuthenticate, hProxyAuthorization, hRange, hReferer, hRetryAfter, hServer, hTE, hTrailer, hTransferEncoding, hUpgrade, hUserAgent, hVary, hVia, hWWWAuthenticate, hWarning :: HeaderName+hAccept = "Accept"+hAcceptCharset = "Accept-Charset"+hAcceptEncoding = "Accept-Encoding"+hAcceptLanguage = "Accept-Language"+hAcceptRanges = "Accept-Ranges"+hAge = "Age"+hAllow = "Allow"+hAuthorization = "Authorization"+hCacheControl = "Cache-Control"+hConnection = "Connection"+hContentEncoding = "Content-Encoding"+hContentLanguage = "Content-Language"+hContentLength = "Content-Length"+hContentLocation = "Content-Location"+hContentMD5 = "Content-MD5"+hContentRange = "Content-Range"+hContentType = "Content-Type"+hCookie = "Cookie"+hDate = "Date"+hETag = "ETag"+hExpect = "Expect"+hExpires = "Expires"+hFrom = "From"+hHost = "Host"+hIfMatch = "If-Match"+hIfModifiedSince = "If-Modified-Since"+hIfNoneMatch = "If-None-Match"+hIfRange = "If-Range"+hIfUnmodifiedSince = "If-Unmodified-Since"+hLastModified = "Last-Modified"+hLocation = "Location"+hMaxForwards = "Max-Forwards"+hPragma = "Pragma"+hProxyAuthenticate = "Proxy-Authenticate"+hProxyAuthorization = "Proxy-Authorization"+hRange = "Range"+hReferer = "Referer"+hRetryAfter = "Retry-After"+hServer = "Server"+hTE = "TE"+hTrailer = "Trailer"+hTransferEncoding = "Transfer-Encoding"+hUpgrade = "Upgrade"+hUserAgent = "User-Agent"+hVary = "Vary"+hVia = "Via"+hWWWAuthenticate = "WWW-Authenticate"+hWarning = "Warning" --- | RFC 2616 Byte range (individual). --- +-- | RFC 2616 Byte range (individual).+-- -- Negative indices are not allowed!-data ByteRange +data ByteRange = ByteRangeFrom !Integer | ByteRangeFromTo !Integer !Integer | ByteRangeSuffix !Integer
Network/HTTP/Types/Method.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DeriveDataTypeable #-} module Network.HTTP.Types.Method ( Method@@ -21,6 +22,7 @@ import Data.Array import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8+import Data.Typeable -- | HTTP method (flat string type). type Method = B.ByteString@@ -49,7 +51,7 @@ | CONNECT | OPTIONS | PATCH- deriving (Read, Show, Eq, Ord, Enum, Bounded, Ix)+ deriving (Read, Show, Eq, Ord, Enum, Bounded, Ix, Typeable) -- These are ordered by suspected frequency. More popular methods should go first. -- The reason is that methodList is used with lookup. -- lookup is probably faster for these few cases than setting up an elaborate data structure.
Network/HTTP/Types/Status.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-} module Network.HTTP.Types.Status-(- Status(..)+( Status(..) , mkStatus , status100 , continue100@@ -35,6 +34,8 @@ , useProxy305 , status307 , temporaryRedirect307+, status308+, permanentRedirect308 , status400 , badRequest400 , status401@@ -98,10 +99,10 @@ , statusIsRedirection , statusIsClientError , statusIsServerError-)-where+) where import qualified Data.ByteString as B+import Data.Typeable -- | HTTP Status. --@@ -112,11 +113,9 @@ -- -- Note that the Show instance is only for debugging. data Status- = Status {- statusCode :: Int- , statusMessage :: B.ByteString- }- deriving (Show)+ = Status { statusCode :: Int+ , statusMessage :: B.ByteString+ } deriving (Show, Typeable) instance Eq Status where Status { statusCode = a } == Status { statusCode = b } = a == b@@ -125,48 +124,53 @@ compare Status { statusCode = a } Status { statusCode = b } = a `compare` b instance Enum Status where- fromEnum = statusCode- toEnum 100 = status100- toEnum 101 = status101- toEnum 200 = status200- toEnum 201 = status201- toEnum 202 = status202- toEnum 203 = status203- toEnum 204 = status204- toEnum 205 = status205- toEnum 206 = status206- toEnum 300 = status300- toEnum 301 = status301- toEnum 302 = status302- toEnum 303 = status303- toEnum 304 = status304- toEnum 305 = status305- toEnum 307 = status307- toEnum 400 = status400- toEnum 401 = status401- toEnum 402 = status402- toEnum 403 = status403- toEnum 404 = status404- toEnum 405 = status405- toEnum 406 = status406- toEnum 407 = status407- toEnum 408 = status408- toEnum 409 = status409- toEnum 410 = status410- toEnum 411 = status411- toEnum 412 = status412- toEnum 413 = status413- toEnum 414 = status414- toEnum 415 = status415- toEnum 416 = status416- toEnum 417 = status417- toEnum 500 = status500- toEnum 501 = status501- toEnum 502 = status502- toEnum 503 = status503- toEnum 504 = status504- toEnum 505 = status505- toEnum c = mkStatus c B.empty+ fromEnum = statusCode+ toEnum 100 = status100+ toEnum 101 = status101+ toEnum 200 = status200+ toEnum 201 = status201+ toEnum 202 = status202+ toEnum 203 = status203+ toEnum 204 = status204+ toEnum 205 = status205+ toEnum 206 = status206+ toEnum 300 = status300+ toEnum 301 = status301+ toEnum 302 = status302+ toEnum 303 = status303+ toEnum 304 = status304+ toEnum 305 = status305+ toEnum 307 = status307+ toEnum 308 = status308+ toEnum 400 = status400+ toEnum 401 = status401+ toEnum 402 = status402+ toEnum 403 = status403+ toEnum 404 = status404+ toEnum 405 = status405+ toEnum 406 = status406+ toEnum 407 = status407+ toEnum 408 = status408+ toEnum 409 = status409+ toEnum 410 = status410+ toEnum 411 = status411+ toEnum 412 = status412+ toEnum 413 = status413+ toEnum 414 = status414+ toEnum 415 = status415+ toEnum 416 = status416+ toEnum 417 = status417+ toEnum 428 = status428+ toEnum 429 = status429+ toEnum 431 = status431+ toEnum 500 = status500+ toEnum 501 = status501+ toEnum 502 = status502+ toEnum 503 = status503+ toEnum 504 = status504+ toEnum 505 = status505+ toEnum 511 = status511+ toEnum c = mkStatus c B.empty -- | Create a Status from status code and message. mkStatus :: Int -> B.ByteString -> Status@@ -299,6 +303,14 @@ -- | Temporary Redirect 307 temporaryRedirect307 :: Status temporaryRedirect307 = status307++-- | Permanent Redirect 308+status308 :: Status+status308 = mkStatus 308 "Permanent Redirect"++-- | Permanent Redirect 308+permanentRedirect308 :: Status+permanentRedirect308 = status308 -- | Bad Request 400 status400 :: Status
Network/HTTP/Types/URI.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, CPP #-} module Network.HTTP.Types.URI ( -- * Query string@@ -38,7 +38,9 @@ import Data.Char import Data.List import Data.Maybe+#if __GLASGOW_HASKELL__ < 710 import Data.Monoid+#endif import Data.Text (Text) import Data.Text.Encoding (encodeUtf8, decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode)@@ -215,7 +217,7 @@ x' <- hexVal x (y, ys) <- B.uncons xs y' <- hexVal y- Just $ (combine x' y', ys)+ Just (combine x' y', ys) Just (w, ws) -> Just (w, ws) hexVal w | 48 <= w && w <= 57 = Just $ w - 48 -- 0 - 9
Network/HTTP/Types/Version.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DeriveDataTypeable #-} module Network.HTTP.Types.Version ( HttpVersion(..)@@ -7,15 +8,17 @@ ) where +import Data.Typeable+ -- | HTTP Version.--- +-- -- Note that the Show instance is intended merely for debugging.-data HttpVersion +data HttpVersion = HttpVersion {- httpMajor :: !Int + httpMajor :: !Int , httpMinor :: !Int }- deriving (Eq, Ord)+ deriving (Eq, Ord, Typeable) instance Show HttpVersion where show (HttpVersion major minor) = "HTTP/" ++ show major ++ "." ++ show minor
http-types.cabal view
@@ -1,5 +1,5 @@ Name: http-types-Version: 0.8.6+Version: 0.9 Synopsis: Generic HTTP types for Haskell (for both client and server code). Description: Generic HTTP types for Haskell (for both client and server code). Homepage: https://github.com/aristidb/http-types@@ -16,7 +16,7 @@ Source-repository this type: git location: https://github.com/aristidb/http-types.git- tag: 0.8.6+ tag: 0.9 Source-repository head type: git