aboutsummaryrefslogtreecommitdiff
path: root/ch16
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2025-08-26 13:46:13 +0200
committerJan Sucan <jan@jansucan.com>2025-08-26 13:46:13 +0200
commitddec828c92aea78edb4da0d9f48097f5ecb31672 (patch)
tree1fb3df1897ab7b2d1b5b27e976573498877f3ff6 /ch16
parent21f0efea7852999d1797930131b3219232a735bc (diff)
16_a_1: Simplify the test requests
Diffstat (limited to 'ch16')
-rw-r--r--ch16/16_a_1.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/ch16/16_a_1.hs b/ch16/16_a_1.hs
index 9f8bc2f..9ed6116 100644
--- a/ch16/16_a_1.hs
+++ b/ch16/16_a_1.hs
@@ -79,7 +79,7 @@ testReqNoContentLength = intercalate "\r\n" [
"Accept: text/html",
"",
"Hello World!"
- ] ++ "\r\n"
+ ]
testReqContentLength :: Integer -> String
testReqContentLength len = intercalate "\r\n" [
@@ -90,7 +90,7 @@ testReqContentLength len = intercalate "\r\n" [
"Content-Length: " ++ show len,
"",
"Hello World!"
- ] ++ "\r\n"
+ ]
-- ghci> :l 16_a_1.hs
@@ -98,7 +98,7 @@ testReqContentLength len = intercalate "\r\n" [
-- Ok, one module loaded.
-- ghci> runParser p_request unlimitedContentLength "" testReqNoContentLength
--- Right (HttpRequest {reqMethod = Post, reqURL = "index.html", reqHeaders = [("Host","book.realworldhaskell.org"),("User-Agent","Mozilla/5.0"),("Accept","text/html")], reqBody = Just "Hello World!\r\n"})
+-- Right (HttpRequest {reqMethod = Post, reqURL = "index.html", reqHeaders = [("Host","book.realworldhaskell.org"),("User-Agent","Mozilla/5.0"),("Accept","text/html")], reqBody = Just "Hello World!"})
-- ghci> runParser p_request unlimitedContentLength "" (testReqContentLength 0)
-- Right (HttpRequest {reqMethod = Post, reqURL = "index.html", reqHeaders = [("Host","book.realworldhaskell.org"),("User-Agent","Mozilla/5.0"),("Accept","text/html"),("Content-Length","0")], reqBody = Just ""})
@@ -107,4 +107,4 @@ testReqContentLength len = intercalate "\r\n" [
-- Right (HttpRequest {reqMethod = Post, reqURL = "index.html", reqHeaders = [("Host","book.realworldhaskell.org"),("User-Agent","Mozilla/5.0"),("Accept","text/html"),("Content-Length","7")], reqBody = Just "Hello W"})
-- ghci> runParser p_request unlimitedContentLength "" (testReqContentLength 123)
--- Right (HttpRequest {reqMethod = Post, reqURL = "index.html", reqHeaders = [("Host","book.realworldhaskell.org"),("User-Agent","Mozilla/5.0"),("Accept","text/html"),("Content-Length","123")], reqBody = Just "Hello World!\r\n"})
+-- Right (HttpRequest {reqMethod = Post, reqURL = "index.html", reqHeaders = [("Host","book.realworldhaskell.org"),("User-Agent","Mozilla/5.0"),("Accept","text/html"),("Content-Length","123")], reqBody = Just "Hello World!"})