Refactor a bit to make pattern matching happy and makeMultipart only work on multipart data.
This commit is contained in:
parent
59eb67e087
commit
928be6991e
@ -546,13 +546,21 @@ request reqBuilder = do
|
|||||||
let cookies = M.filter (checkCookieTime currentUtc) oldCookies
|
let cookies = M.filter (checkCookieTime currentUtc) oldCookies
|
||||||
cookiesForPath = M.filter (checkCookiePath path) cookies
|
cookiesForPath = M.filter (checkCookiePath path) cookies
|
||||||
|
|
||||||
let maker = case rbdPostData of
|
let req = case rbdPostData of
|
||||||
MultipleItemsPostData x ->
|
MultipleItemsPostData x ->
|
||||||
if DL.any isFile x
|
if DL.any isFile x
|
||||||
then makeMultipart
|
then (multipart x)
|
||||||
else makeSinglepart
|
else singlepart
|
||||||
BinaryPostData _ -> makeSinglepart
|
BinaryPostData _ -> singlepart
|
||||||
let req = maker cookiesForPath rbdPostData rbdMethod rbdHeaders path rbdGets
|
where singlepart = makeSinglepart cookiesForPath rbdPostData rbdMethod rbdHeaders path rbdGets
|
||||||
|
multipart x = makeMultipart cookiesForPath x rbdMethod rbdHeaders path rbdGets
|
||||||
|
-- let maker = case rbdPostData of
|
||||||
|
-- MultipleItemsPostData x ->
|
||||||
|
-- if DL.any isFile x
|
||||||
|
-- then makeMultipart
|
||||||
|
-- else makeSinglepart
|
||||||
|
-- BinaryPostData _ -> makeSinglepart
|
||||||
|
-- let req = maker cookiesForPath rbdPostData rbdMethod rbdHeaders path rbdGets
|
||||||
response <- liftIO $ runSession (srequest req) app
|
response <- liftIO $ runSession (srequest req) app
|
||||||
let newCookies = map (Cookie.parseSetCookie . snd) $ DL.filter (("Set-Cookie"==) . fst) $ simpleHeaders response
|
let newCookies = map (Cookie.parseSetCookie . snd) $ DL.filter (("Set-Cookie"==) . fst) $ simpleHeaders response
|
||||||
cookies' = M.fromList [(Cookie.setCookieName c, c) | c <- newCookies] `M.union` cookies
|
cookies' = M.fromList [(Cookie.setCookieName c, c) | c <- newCookies] `M.union` cookies
|
||||||
@ -573,11 +581,17 @@ request reqBuilder = do
|
|||||||
boundary :: String
|
boundary :: String
|
||||||
boundary = "*******noneedtomakethisrandom"
|
boundary = "*******noneedtomakethisrandom"
|
||||||
separator = BS8.concat ["--", BS8.pack boundary, "\r\n"]
|
separator = BS8.concat ["--", BS8.pack boundary, "\r\n"]
|
||||||
makeMultipart cookies rbdPostData method extraHeaders urlPath urlQuery =
|
makeMultipart :: M.Map a0 Cookie.SetCookie
|
||||||
SRequest simpleRequest' (simpleRequestBody' rbdPostData)
|
-> [RequestPart]
|
||||||
where simpleRequestBody' (MultipleItemsPostData x) =
|
-> H.Method
|
||||||
|
-> [H.Header]
|
||||||
|
-> T.Text
|
||||||
|
-> H.Query
|
||||||
|
-> SRequest
|
||||||
|
makeMultipart cookies parts method extraHeaders urlPath urlQuery =
|
||||||
|
SRequest simpleRequest' (simpleRequestBody' parts)
|
||||||
|
where simpleRequestBody' x =
|
||||||
BSL8.fromChunks [multiPartBody x]
|
BSL8.fromChunks [multiPartBody x]
|
||||||
-- simpleRequestBody' (BinaryPostData _) = ""
|
|
||||||
simpleRequest' = mkRequest
|
simpleRequest' = mkRequest
|
||||||
[ ("Cookie", cookieValue)
|
[ ("Cookie", cookieValue)
|
||||||
, ("Content-Type", contentTypeValue)]
|
, ("Content-Type", contentTypeValue)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user