yesod-test: correction to PR for multipart
This commit is contained in:
parent
3f98190645
commit
08a9632eba
@ -1242,9 +1242,8 @@ request reqBuilder = do
|
|||||||
BS8.concat $ separator : [BS8.concat [multipartPart p, separator] | p <- parts]
|
BS8.concat $ separator : [BS8.concat [multipartPart p, separator] | p <- parts]
|
||||||
multipartPart (ReqKvPart k v) = BS8.concat
|
multipartPart (ReqKvPart k v) = BS8.concat
|
||||||
[ "Content-Disposition: form-data; "
|
[ "Content-Disposition: form-data; "
|
||||||
, "name=\"", enc k, "\"\r\n\r\n"
|
, "name=\"", TE.encodeUtf8 k, "\"\r\n\r\n"
|
||||||
, enc v, "\r\n"]
|
, TE.encodeUtf8 v, "\r\n"]
|
||||||
where enc = H.urlEncode False . TE.encodeUtf8
|
|
||||||
multipartPart (ReqFilePart k v bytes mime) = BS8.concat
|
multipartPart (ReqFilePart k v bytes mime) = BS8.concat
|
||||||
[ "Content-Disposition: form-data; "
|
[ "Content-Disposition: form-data; "
|
||||||
, "name=\"", TE.encodeUtf8 k, "\"; "
|
, "name=\"", TE.encodeUtf8 k, "\"; "
|
||||||
|
|||||||
@ -146,10 +146,10 @@ main = hspec $ do
|
|||||||
setMethod "POST"
|
setMethod "POST"
|
||||||
setUrl $ LiteAppRoute ["post"]
|
setUrl $ LiteAppRoute ["post"]
|
||||||
-- If value uses special characters,
|
-- If value uses special characters,
|
||||||
addPostParam "foo" "foo+bar%41&baz"
|
addPostParam "foo" "foo+bar%41<&baz"
|
||||||
statusIs 200
|
statusIs 200
|
||||||
-- They pass through the server correctly.
|
-- They pass through the server correctly.
|
||||||
bodyEquals "foo+bar%41&baz"
|
bodyEquals "foo+bar%41<&baz"
|
||||||
yit "labels" $ do
|
yit "labels" $ do
|
||||||
get ("/form" :: Text)
|
get ("/form" :: Text)
|
||||||
statusIs 200
|
statusIs 200
|
||||||
@ -157,13 +157,13 @@ main = hspec $ do
|
|||||||
request $ do
|
request $ do
|
||||||
setMethod "POST"
|
setMethod "POST"
|
||||||
setUrl ("/form" :: Text)
|
setUrl ("/form" :: Text)
|
||||||
byLabel "Some Label" "foo+bar%41&baz"
|
byLabel "Some Label" "foo+bar%41<&baz"
|
||||||
fileByLabel "Some File" "test/main.hs" "text/plain"
|
fileByLabel "Some File" "test/main.hs" "text/plain"
|
||||||
addToken
|
addToken
|
||||||
statusIs 200
|
statusIs 200
|
||||||
-- The '%', '&' get further encoded because "/form"
|
-- The '<' and '&' get encoded to HTML entities because
|
||||||
-- (unlike "/post") uses toHtml.
|
-- "/form" (unlike "/post") uses toHtml.
|
||||||
bodyEquals "foo+bar%2541&baz"
|
bodyEquals "foo+bar%41<&baz"
|
||||||
yit "labels WForm" $ do
|
yit "labels WForm" $ do
|
||||||
get ("/wform" :: Text)
|
get ("/wform" :: Text)
|
||||||
statusIs 200
|
statusIs 200
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user