summaryrefslogtreecommitdiff
path: root/src/Network/AWS/Request.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/AWS/Request.hs')
-rw-r--r--src/Network/AWS/Request.hs33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/Network/AWS/Request.hs b/src/Network/AWS/Request.hs
index 67e041d..42f2ca9 100644
--- a/src/Network/AWS/Request.hs
+++ b/src/Network/AWS/Request.hs
@@ -36,8 +36,9 @@ module Network.AWS.Request
-- ** Constructors
, defaultRequest
- -- ** Hashing
- , contentMD5
+ -- ** Operation Plugins
+ , contentMD5Header
+ , expectHeader
-- ** Lenses
, requestHeaders
@@ -98,7 +99,9 @@ postQuery s x = Request
}
postBody :: (ToRequest a, ToBody a) => Service -> a -> Request a
-postBody s x = putBody s x & rqMethod .~ POST
+postBody s x = defaultRequest s x
+ & rqMethod .~ POST
+ & rqBody .~ toBody x
putXML :: (ToRequest a, ToElement a) => Service -> a -> Request a
putXML s x = defaultRequest s x
@@ -112,9 +115,8 @@ putJSON s x = defaultRequest s x
putBody :: (ToRequest a, ToBody a) => Service -> a -> Request a
putBody s x = defaultRequest s x
- & rqMethod .~ PUT
- & rqBody .~ toBody x
- & rqHeaders %~ hdr hExpect "100-continue"
+ & rqMethod .~ PUT
+ & rqBody .~ toBody x
defaultRequest :: ToRequest a => Service -> a -> Request a
defaultRequest s x = Request
@@ -126,14 +128,6 @@ defaultRequest s x = Request
, _rqBody = ""
}
-contentMD5 :: Request a -> Request a
-contentMD5 rq
- | missing, Just x <- md5 = rq & rqHeaders %~ hdr HTTP.hContentMD5 x
- | otherwise = rq
- where
- missing = isNothing $ lookup HTTP.hContentMD5 (_rqHeaders rq)
- md5 = md5Base64 (_rqBody rq)
-
queryString :: Lens' Client.Request ByteString
queryString f x =
f (Client.queryString x) <&> \y -> x { Client.queryString = y }
@@ -159,3 +153,14 @@ requestURL x = scheme
n -> ":" <> toBS n
secure = Client.secure x
+
+contentMD5Header :: Request a -> Request a
+contentMD5Header rq
+ | missing, Just x <- md5 = rq & rqHeaders %~ hdr HTTP.hContentMD5 x
+ | otherwise = rq
+ where
+ missing = isNothing $ lookup HTTP.hContentMD5 (_rqHeaders rq)
+ md5 = md5Base64 (_rqBody rq)
+
+expectHeader :: Request a -> Request a
+expectHeader = rqHeaders %~ hdr hExpect "100-continue"