http-types 0.9 → 0.9.1
raw patch · 6 files changed
+75/−3 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.Types: parseByteRanges :: ByteString -> Maybe ByteRanges
+ Network.HTTP.Types.Header: parseByteRanges :: ByteString -> Maybe ByteRanges
+ Network.HTTP.Types.Status: status422 :: Status
+ Network.HTTP.Types.Status: unprocessableEntity422 :: Status
Files
- CHANGELOG +8/−0
- Network/HTTP/Types.hs +1/−0
- Network/HTTP/Types/Header.hs +46/−0
- Network/HTTP/Types/Status.hs +13/−0
- README +4/−0
- http-types.cabal +3/−3
+ CHANGELOG view
@@ -0,0 +1,8 @@+* 0.9.1 [2016-06-04]++New function: parseByteRanges.+Support for HTTP status 422 "Unprocessable Entity" (RFC 4918).++* 0.9 [2015-10-09]++No changelog was maintained up to version 0.9.
Network/HTTP/Types.hs view
@@ -144,6 +144,7 @@ , ByteRanges , renderByteRangesBuilder , renderByteRanges+, parseByteRanges -- * URI -- ** Query string , QueryItem
Network/HTTP/Types/Header.hs view
@@ -62,6 +62,7 @@ , ByteRanges , renderByteRangesBuilder , renderByteRanges+, parseByteRanges ) where @@ -72,6 +73,7 @@ import qualified Blaze.ByteString.Builder as Blaze import qualified Blaze.ByteString.Builder.Char8 as Blaze import qualified Data.ByteString as B+import qualified Data.ByteString.Char8 as B8 import qualified Data.CaseInsensitive as CI import Data.ByteString.Char8 () {-IsString-} import Data.Typeable (Typeable)@@ -167,3 +169,47 @@ renderByteRanges :: ByteRanges -> B.ByteString renderByteRanges = Blaze.toByteString . renderByteRangesBuilder++-- | Parse the value of a Range header into a 'ByteRanges'.+--+-- >>> parseByteRanges "error"+-- Nothing+-- >>> parseByteRanges "bytes=0-499"+-- Just [ByteRangeFromTo 0 499]+-- >>> parseByteRanges "bytes=500-999"+-- Just [ByteRangeFromTo 500 999]+-- >>> parseByteRanges "bytes=-500"+-- Just [ByteRangeSuffix 500]+-- >>> parseByteRanges "bytes=9500-"+-- Just [ByteRangeFrom 9500]+-- >>> parseByteRanges "bytes=0-0,-1"+-- Just [ByteRangeFromTo 0 0,ByteRangeSuffix 1]+-- >>> parseByteRanges "bytes=500-600,601-999"+-- Just [ByteRangeFromTo 500 600,ByteRangeFromTo 601 999]+-- >>> parseByteRanges "bytes=500-700,601-999"+-- Just [ByteRangeFromTo 500 700,ByteRangeFromTo 601 999]+parseByteRanges :: B.ByteString -> Maybe ByteRanges+parseByteRanges bs1 = do+ bs2 <- stripPrefixB "bytes=" bs1+ (r, bs3) <- range bs2+ ranges (r:) bs3+ where+ range bs2 = do+ (i, bs3) <- B8.readInteger bs2+ if i < 0 -- has prefix "-" ("-0" is not valid, but here treated as "0-")+ then Just (ByteRangeSuffix (negate i), bs3)+ else do+ bs4 <- stripPrefixB "-" bs3+ case B8.readInteger bs4 of+ Just (j, bs5) | j >= i -> Just (ByteRangeFromTo i j, bs5)+ _ -> Just (ByteRangeFrom i, bs4)+ ranges front bs3+ | B.null bs3 = Just (front [])+ | otherwise = do+ bs4 <- stripPrefixB "," bs3+ (r, bs5) <- range bs4+ ranges (front . (r:)) bs5++ stripPrefixB x y+ | x `B.isPrefixOf` y = Just (B.drop (B.length x) y)+ | otherwise = Nothing
Network/HTTP/Types/Status.hs view
@@ -74,6 +74,8 @@ , expectationFailed417 , status418 , imATeaPot418+, status422+, unprocessableEntity422 , status428 , preconditionRequired428 , status429@@ -160,6 +162,7 @@ toEnum 415 = status415 toEnum 416 = status416 toEnum 417 = status417+ toEnum 422 = status422 toEnum 428 = status428 toEnum 429 = status429 toEnum 431 = status431@@ -463,6 +466,16 @@ -- | I'm a teapot 418 imATeaPot418 :: Status imATeaPot418 = status418++-- | Unprocessable Entity 422+-- (<https://tools.ietf.org/html/rfc4918 RFC 4918>)+status422 :: Status+status422 = mkStatus 422 "Unprocessable Entity"++-- | Unprocessable Entity 422+-- (<https://tools.ietf.org/html/rfc4918 RFC 4918>)+unprocessableEntity422 :: Status+unprocessableEntity422 = status422 -- | Precondition Required 428 -- (<https://tools.ietf.org/html/rfc6585 RFC 6585>)
README view
@@ -1,1 +1,5 @@ Generic HTTP types for Haskell (for both client and server code).++This library also contains some utility functions, e.g. related to URI+handling, that are not necessarily restricted in use to HTTP, but the scope is+restricted to things that are useful inside HTTP, i.e. no FTP URI parsing.
http-types.cabal view
@@ -1,5 +1,5 @@ Name: http-types-Version: 0.9+Version: 0.9.1 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@@ -10,13 +10,13 @@ Copyright: (C) 2011 Aristid Breitkreuz Category: Network, Web Build-type: Simple-Extra-source-files: README+Extra-source-files: README, CHANGELOG Cabal-version: >=1.8 Source-repository this type: git location: https://github.com/aristidb/http-types.git- tag: 0.9+ tag: 0.9.1 Source-repository head type: git