packages feed

azurify 0.4.0.1 → 0.4.0.2

raw patch · 3 files changed

+23/−12 lines, 3 filesdep −HTTP

Dependencies removed: HTTP

Files

Azure.hs view
@@ -36,16 +36,17 @@ #endif  import Network.HTTP.Conduit+import Network.HTTP.Types (urlDecode, renderQuery, simpleQueryToQuery) import Network.HTTP.Types.Header import Network.HTTP.Types.Status-import Network.HTTP.Base (urlEncodeVars, urlDecode) import System.Locale import System.IO (openBinaryFile, IOMode(..)) import Data.List import Data.Time import Data.Char (isSpace) import Data.CaseInsensitive (foldedCase)-import Data.Maybe (fromJust, isJust)+import Data.Maybe (fromJust, isJust, listToMaybe, fromMaybe)+import Data.Ord (comparing) import Network (withSocketsDo)  import qualified Data.ByteString as B@@ -257,10 +258,22 @@         let headers = ("x-ms-version", "2011-08-18")                     : ("x-ms-date", now)                     : extraHeaders ++ requestHeaders initReq+        let getHeader hdr = listToMaybe $ map snd $ filter (\(a,b) -> a == hdr) headers         let signData = defaultSignData { verb = reqType                                        , contentLength = if reqType `elem` ["PUT", "DELETE"] || not (B.null reqBody) then B8.pack $ show $ B.length reqBody else ""                                        , canonicalizedHeaders = canonicalizeHeaders headers-                                       , canonicalizedResource = canonicalizeResource account resource params }+                                       , canonicalizedResource = canonicalizeResource account resource params+                                       , contentType = fromMaybe "" $ getHeader "Content-Type"+                                       , contentEncoding = fromMaybe "" $ getHeader "Content-Encoding"+                                       , contentLanguage = fromMaybe "" $ getHeader "Content-Language"+                                       , contentMD5 = fromMaybe "" $ getHeader "Content-MD5"+                                       , date = ""+                                       , ifModifiedSince = fromMaybe "" $ getHeader "If-Modified-Since"+                                       , ifMatch = fromMaybe "" $ getHeader "If-Match"+                                       , ifNoneMatch = fromMaybe "" $ getHeader "If-None-Match"+                                       , ifUnmodifiedSince = fromMaybe "" $ getHeader "If-Unmodified-Since"+                                       , range = fromMaybe "" $ getHeader "Range"+                                       }         let signature = sign authKey signData         let authHeader = ("Authorization", "SharedKey " <> account <> ":" <> signature)         let request = initReq { method = reqType@@ -270,8 +283,7 @@         httpLbs request manager  encodeParams :: [(B.ByteString, B.ByteString)] -> B.ByteString-encodeParams [] = ""-encodeParams vars = ("?" <>) $ B8.pack $ urlEncodeVars $ map (\(a,b) -> (B8.unpack a, B8.unpack b)) vars+encodeParams = renderQuery True . simpleQueryToQuery  liftToString :: (String -> String) -> B8.ByteString -> B8.ByteString liftToString f = B8.pack . f . B8.unpack@@ -285,7 +297,7 @@  canonicalizeResource :: B.ByteString -> B.ByteString -> [(B.ByteString, B.ByteString)] -> B.ByteString canonicalizeResource accountName uriPath params = "/" <> accountName <> uriPath <> "\n" <> canonParams-    where canonParams = strip $ B.intercalate "\n" $ map (\(k,v) -> liftToString urlDecode k <> ":" <> liftToString urlDecode v) $ sortBy (\(k1,_) (k2,_) -> compare k1 k2) params+    where canonParams = strip $ B.intercalate "\n" $ map (\(k,v) -> (urlDecode True) k <> ":" <> (urlDecode True v)) $ sortBy (comparing fst) params  strip :: B.ByteString -> B.ByteString strip = f . f
azurify.cabal view
@@ -1,5 +1,5 @@ name:                azurify-version:             0.4.0.1+version:             0.4.0.2 synopsis:            A simple library for accessing Azure blob storage description:         An interface for a few basic functions of the Microsoft Azure blob storage. Creating and deleting containers as well as uploading, downloading and breaking leases of blobs is supported. homepage:            http://arnovanlumig.com/azure@@ -61,8 +61,7 @@     utf8-string >= 0.3.7,     old-locale >= 1.0.0.4,     filepath,-    unix-compat,-    HTTP+    unix-compat    if !flag(no-hxt)     build-depends:@@ -75,6 +74,8 @@   if flag(no-hxt)       cpp-options:   -DNO_XML +  ghc-options: -O2 -rtsopts+  -- ld-options: -static -pthread   extensions:     OverloadedStrings     CPP@@ -101,8 +102,7 @@     cmdargs >= 0.10,     directory >= 1.1.0.2,     filepath,-    unix-compat,-    HTTP+    unix-compat    if !flag(no-hxt)     build-depends:
readme.md view
@@ -16,7 +16,6 @@ - Breaking a blob lease  The following features are *not* implemented (yet):-- Setting container and blob metadata - Doing anything else with leases - Anything with snapshots - Proper error handling