parent
ac66323394
commit
a79f73a040
1 changed files with 7 additions and 6 deletions
|
@ -1242,8 +1242,9 @@ request reqBuilder = do
|
|||
BS8.concat $ separator : [BS8.concat [multipartPart p, separator] | p <- parts]
|
||||
multipartPart (ReqKvPart k v) = BS8.concat
|
||||
[ "Content-Disposition: form-data; "
|
||||
, "name=\"", TE.encodeUtf8 k, "\"\r\n\r\n"
|
||||
, TE.encodeUtf8 v, "\r\n"]
|
||||
, "name=\"", enc k, "\"\r\n\r\n"
|
||||
, enc v, "\r\n"]
|
||||
where enc = H.urlEncode False . TE.encodeUtf8
|
||||
multipartPart (ReqFilePart k v bytes mime) = BS8.concat
|
||||
[ "Content-Disposition: form-data; "
|
||||
, "name=\"", TE.encodeUtf8 k, "\"; "
|
||||
|
@ -1266,14 +1267,14 @@ request reqBuilder = do
|
|||
([ ("Cookie", cookieValue) ] ++ headersForPostData rbdPostData)
|
||||
method extraHeaders urlPath urlQuery)
|
||||
simpleRequestBody' (MultipleItemsPostData x) =
|
||||
BSL8.fromChunks $ return $ TE.encodeUtf8 $ T.intercalate "&"
|
||||
$ map singlepartPart x
|
||||
BSL8.fromChunks $ return $ H.renderSimpleQuery False
|
||||
$ concatMap singlepartPart x
|
||||
simpleRequestBody' (BinaryPostData x) = x
|
||||
cookieValue = Builder.toByteString $ Cookie.renderCookies cookiePairs
|
||||
cookiePairs = [ (Cookie.setCookieName c, Cookie.setCookieValue c)
|
||||
| c <- map snd $ M.toList cookies ]
|
||||
singlepartPart (ReqFilePart _ _ _ _) = ""
|
||||
singlepartPart (ReqKvPart k v) = T.concat [k,"=",v]
|
||||
singlepartPart (ReqFilePart _ _ _ _) = []
|
||||
singlepartPart (ReqKvPart k v) = [(TE.encodeUtf8 k, TE.encodeUtf8 v)]
|
||||
|
||||
-- If the request appears to be submitting a form (has key-value pairs) give it the form-urlencoded Content-Type.
|
||||
-- The previous behavior was to always use the form-urlencoded Content-Type https://github.com/yesodweb/yesod/issues/1063
|
||||
|
|
Loading…
Reference in a new issue