Fix shadowing warnings

This commit is contained in:
Aditya Manthramurthy 2017-01-10 00:58:39 +05:30
parent 0648e4965e
commit 1ad670a328
3 changed files with 26 additions and 26 deletions

View File

@ -36,11 +36,11 @@ import Network.Minio.Sign.V4
executeRequest :: RequestInfo -> Minio (Response LByteString) executeRequest :: RequestInfo -> Minio (Response LByteString)
executeRequest ri = do executeRequest ri = do
let PayloadSingle pload = payload ri let PayloadSingle pload = riPayload ri
phash = hashSHA256 pload phash = hashSHA256 pload
newRI = ri { newRI = ri {
payloadHash = phash riPayloadHash = phash
, headers = ("x-amz-content-sha256", phash) : (headers ri) , riHeaders = ("x-amz-content-sha256", phash) : (riHeaders ri)
} }
ci <- asks mcConnInfo ci <- asks mcConnInfo
@ -50,12 +50,12 @@ executeRequest ri = do
mgr <- asks mcConnManager mgr <- asks mcConnManager
let req = NC.defaultRequest { let req = NC.defaultRequest {
NC.method = method newRI NC.method = riMethod newRI
, NC.secure = connectIsSecure ci , NC.secure = connectIsSecure ci
, NC.host = encodeUtf8 $ connectHost ci , NC.host = encodeUtf8 $ connectHost ci
, NC.port = connectPort ci , NC.port = connectPort ci
, NC.path = getPathFromRI ri , NC.path = getPathFromRI ri
, NC.queryString = HT.renderQuery False $ queryParams ri , NC.queryString = HT.renderQuery False $ riQueryParams ri
, NC.requestHeaders = reqHeaders , NC.requestHeaders = reqHeaders
, NC.requestBody = NC.RequestBodyBS pload , NC.requestBody = NC.RequestBodyBS pload
} }
@ -65,11 +65,11 @@ executeRequest ri = do
mkStreamRequest :: RequestInfo mkStreamRequest :: RequestInfo
-> Minio (Response (C.ResumableSource Minio ByteString)) -> Minio (Response (C.ResumableSource Minio ByteString))
mkStreamRequest ri = do mkStreamRequest ri = do
let PayloadSingle pload = payload ri let PayloadSingle pload = riPayload ri
phash = hashSHA256 pload phash = hashSHA256 pload
newRI = ri { newRI = ri {
payloadHash = phash riPayloadHash = phash
, headers = ("x-amz-content-sha256", phash) : (headers ri) , riHeaders = ("x-amz-content-sha256", phash) : (riHeaders ri)
} }
ci <- asks mcConnInfo ci <- asks mcConnInfo
@ -79,12 +79,12 @@ mkStreamRequest ri = do
mgr <- asks mcConnManager mgr <- asks mcConnManager
let req = NC.defaultRequest { let req = NC.defaultRequest {
NC.method = method newRI NC.method = riMethod newRI
, NC.secure = connectIsSecure ci , NC.secure = connectIsSecure ci
, NC.host = encodeUtf8 $ connectHost ci , NC.host = encodeUtf8 $ connectHost ci
, NC.port = connectPort ci , NC.port = connectPort ci
, NC.path = getPathFromRI ri , NC.path = getPathFromRI ri
, NC.queryString = HT.renderQuery False $ queryParams ri , NC.queryString = HT.renderQuery False $ riQueryParams ri
, NC.requestHeaders = reqHeaders , NC.requestHeaders = reqHeaders
, NC.requestBody = NC.RequestBodyBS pload , NC.requestBody = NC.RequestBodyBS pload
} }

View File

@ -61,25 +61,25 @@ data Payload = PayloadSingle ByteString
deriving (Show, Eq) deriving (Show, Eq)
data RequestInfo = RequestInfo { data RequestInfo = RequestInfo {
method :: Method riMethod :: Method
, bucket :: Maybe Bucket , riBucket :: Maybe Bucket
, object :: Maybe Object , riObject :: Maybe Object
, queryParams :: Query , riQueryParams :: Query
, headers :: [Header] , riHeaders :: [Header]
, payload :: Payload , riPayload :: Payload
, payloadHash :: ByteString , riPayloadHash :: ByteString
, region :: Maybe Location , riRegion :: Maybe Location
} }
getPathFromRI :: RequestInfo -> ByteString getPathFromRI :: RequestInfo -> ByteString
getPathFromRI ri = B.concat $ parts getPathFromRI ri = B.concat $ parts
where where
objPart = maybe [] (\o -> ["/", encodeUtf8 o]) $ object ri objPart = maybe [] (\o -> ["/", encodeUtf8 o]) $ riObject ri
parts = maybe ["/"] (\b -> "/" : encodeUtf8 b : objPart) $ bucket ri parts = maybe ["/"] (\b -> "/" : encodeUtf8 b : objPart) $ riBucket ri
getRegionFromRI :: RequestInfo -> Text getRegionFromRI :: RequestInfo -> Text
getRegionFromRI ri = maybe "us-east-1" identity (region ri) getRegionFromRI ri = maybe "us-east-1" identity (riRegion ri)
data MinioErr = MErrMsg ByteString data MinioErr = MErrMsg ByteString
| MErrHttp HttpException | MErrHttp HttpException

View File

@ -77,14 +77,14 @@ signV4 ci ri = do
-- an updated list of headers. -- an updated list of headers.
signV4AtTime :: UTCTime -> ConnectInfo -> RequestInfo -> SignV4Data signV4AtTime :: UTCTime -> ConnectInfo -> RequestInfo -> SignV4Data
signV4AtTime ts ci ri = signV4AtTime ts ci ri =
SignV4Data ts scope canonicalRequest headersToSign (headers ri) outHeaders stringToSign signingKey SignV4Data ts scope canonicalRequest headersToSign (riHeaders ri) outHeaders stringToSign signingKey
where where
outHeaders = authHeader : headersWithDate outHeaders = authHeader : headersWithDate
timeBS = awsTimeFormatBS ts timeBS = awsTimeFormatBS ts
dateHeader = (mk "X-Amz-Date", timeBS) dateHeader = (mk "X-Amz-Date", timeBS)
hostHeader = (mk "host", encodeUtf8 $ connectHost ci) hostHeader = (mk "host", encodeUtf8 $ connectHost ci)
headersWithDate = dateHeader : hostHeader : (headers ri) headersWithDate = dateHeader : hostHeader : (riHeaders ri)
authHeader = (mk "Authorization", authHeaderValue) authHeader = (mk "Authorization", authHeaderValue)
@ -134,12 +134,12 @@ getHeadersToSign h =
getCanonicalRequest :: RequestInfo -> [(ByteString, ByteString)] -> ByteString getCanonicalRequest :: RequestInfo -> [(ByteString, ByteString)] -> ByteString
getCanonicalRequest ri headersForSign = B.intercalate "\n" $ [ getCanonicalRequest ri headersForSign = B.intercalate "\n" $ [
method ri, riMethod ri,
uriEncode False path, uriEncode False path,
canonicalQueryString, canonicalQueryString,
canonicalHeaders, canonicalHeaders,
signedHeaders, signedHeaders,
payloadHash ri riPayloadHash ri
] ]
where where
path = getPathFromRI ri path = getPathFromRI ri
@ -148,7 +148,7 @@ getCanonicalRequest ri headersForSign = B.intercalate "\n" $ [
map (\(x, y) -> B.concat [x, "=", y]) $ map (\(x, y) -> B.concat [x, "=", y]) $
sort $ map (\(x, y) -> sort $ map (\(x, y) ->
(uriEncode True x, maybe "" (uriEncode True) y)) $ (uriEncode True x, maybe "" (uriEncode True) y)) $
queryParams ri riQueryParams ri
canonicalHeaders = B.concat $ canonicalHeaders = B.concat $
map (\(x, y) -> B.concat [x, ":", y, "\n"]) $ map (\(x, y) -> B.concat [x, ":", y, "\n"]) $