packages feed

web-encodings 0.3.0.1 → 0.3.0.2

raw patch · 2 files changed

+3/−105 lines, 2 filesdep ~convertible-textdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: convertible-text, text

API changes (from Hackage documentation)

Files

runtests.hs view
@@ -20,7 +20,6 @@ import Web.Encodings.StringLike (StringLike) import Control.Arrow ((***)) import qualified Data.ByteString as B-import Network.Wai  main :: IO () main = defaultMain [tests]@@ -51,7 +50,6 @@     , allTests "Strict Text" (undefined :: TS.Text)     , allTests "Lazy Text" (undefined :: TL.Text)     , testCase "parse post" huParsePost-    , testCase "parse request body" huParseRequestBody     ]  qcEncodeDecodeUrl :: StringLike a => a -> a -> Bool@@ -198,103 +196,3 @@         encoded = SL.pack raw `asTypeOf` dummy         expected = SL.unpackUtf8 bs     expected @=? decodeUrlFailure encoded--huParseRequestBody :: Assertion-huParseRequestBody = t where-    content2 = cs $-        "--AaB03x\n" ++-        "Content-Disposition: form-data; name=\"document\"; filename=\"b.txt\"\n" ++-        "Content-Type: text/plain; charset=iso-8859-1\n\n" ++-        "This is a file.\n" ++-        "It has two lines.\n" ++-        "--AaB03x\n" ++-        "Content-Disposition: form-data; name=\"title\"\n" ++-        "Content-Type: text/plain; charset=iso-8859-1\n\n" ++-        "A File\n" ++-        "--AaB03x\n" ++-        "Content-Disposition: form-data; name=\"summary\"\n" ++-        "Content-Type: text/plain; charset=iso-8859-1\n\n" ++-        "This is my file\n" ++-        "file test\n" ++-        "--AaB03x--"-    content3 = cs "------WebKitFormBoundaryB1pWXPZ6lNr8RiLh\r\nContent-Disposition: form-data; name=\"yaml\"; filename=\"README\"\r\nContent-Type: application/octet-stream\r\n\r\nPhoto blog using Hack.\n\r\n------WebKitFormBoundaryB1pWXPZ6lNr8RiLh--\r\n"-    t = do-        let content1 = cs "foo=bar&baz=bin"-        let ctype1 = cs "application/x-www-form-urlencoded"-        result1 <- parseRequestBody lbsSink $ toRequest ctype1 content1-        assertEqual "parsing post x-www-form-urlencoded"-                    (map (cs *** cs) [("foo", "bar"), ("baz", "bin")], [])-                    result1--        let ctype2 = cs "multipart/form-data; boundary=AaB03x"-        result2 <- parseRequestBody lbsSink $ toRequest ctype2 content2-        let expectedsmap2 =-              [ ("title", "A File")-              , ("summary", "This is my file\nfile test")-              ]-        let expectedfile2 =-              [(cs "document", FileInfo (cs "b.txt") (cs "text/plain") $ cs-                 "This is a file.\nIt has two lines.")]-        let expected2 = (map (cs *** cs) expectedsmap2, expectedfile2)-        assertEqual "parsing post multipart/form-data"-                    expected2-                    result2--        let ctype3 = cs "multipart/form-data; boundary=----WebKitFormBoundaryB1pWXPZ6lNr8RiLh"-        result3 <- parseRequestBody lbsSink $ toRequest ctype3 content3-        let expectedsmap3 = []-        let expectedfile3 = [(cs "yaml", FileInfo (cs "README") (cs "application/octet-stream") $-                                cs "Photo blog using Hack.\n")]-        let expected3 = (expectedsmap3, expectedfile3)-        assertEqual "parsing actual post multipart/form-data"-                    expected3-                    result3--        result2' <- parseRequestBody lbsSink $ toRequest' ctype2 content2-        assertEqual "parsing post multipart/form-data 2"-                    expected2-                    result2-        putStrLn "\n\n\n\n\n"-        result3' <- parseRequestBody lbsSink $ toRequest' ctype3 content3-        assertEqual "parsing actual post multipart/form-data 2"-                    expected3-                    result3'--toRequest :: BS.ByteString -> BS.ByteString -> Request-toRequest ctype content = Request-    { requestHeaders = [(ReqContentType, ctype)]-    , requestBody = toSource content-    , requestMethod = undefined-    , httpVersion = undefined-    , pathInfo = undefined-    , queryString = undefined-    , serverName = undefined-    , serverPort = undefined-    , urlScheme = undefined-    , errorHandler = undefined-    , remoteHost = undefined-    }--toRequest' :: BS.ByteString -> BS.ByteString -> Request-toRequest' ctype content = Request-    { requestHeaders = [(ReqContentType, ctype)]-    , requestBody = toSource' content-    , requestMethod = undefined-    , httpVersion = undefined-    , pathInfo = undefined-    , queryString = undefined-    , serverName = undefined-    , serverPort = undefined-    , urlScheme = undefined-    , errorHandler = undefined-    , remoteHost = undefined-    }--toSource :: BS.ByteString -> Source-toSource bs = Source $-    case B.uncons bs of-        Nothing -> return Nothing-        Just (x, xs) -> return $ Just (B.singleton x, toSource xs)--toSource' :: BS.ByteString -> Source-toSource' bs = Source $ return $ Just (bs, Source $ return Nothing)
web-encodings.cabal view
@@ -1,5 +1,5 @@ name:            web-encodings-version:         0.3.0.1+version:         0.3.0.2 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -21,7 +21,7 @@                      time >= 1.1.2.4 && < 1.3,                      old-locale >= 1.0.0.1 && < 1.1,                      bytestring >= 0.9.1.4 && < 0.10,-                     text >= 0.5 && < 0.9,+                     text >= 0.5 && < 0.10,                      failure >= 0.0.0 && < 0.2,                      directory >= 1 && < 1.1     exposed-modules: Web.Encodings@@ -38,7 +38,7 @@                          test-framework-hunit,                          HUnit,                          QuickCheck >= 2 && < 3,-                         convertible-text >= 0.2.0 && < 0.3+                         convertible-text >= 0.2.0 && < 0.4     else         Buildable: False     ghc-options:     -Wall