diff options
| author | 2021-10-23 07:18:42 +0900 | |
|---|---|---|
| committer | 2021-10-23 08:21:15 +0900 | |
| commit | b3ce391d9838dd472ee0fbedcad56f58054e8a60 (patch) | |
| tree | fb06614fd7a9001b30105bf8cd19a51a8cc85080 /test | |
| parent | Merge pull request #48 from pepe/request-body-size (diff) | |
Fix parsing of POST requests in HTTP module
Diffstat (limited to 'test')
| -rw-r--r-- | test/suite0012.janet | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/test/suite0012.janet b/test/suite0012.janet index bdd3032..11fb343 100644 --- a/test/suite0012.janet +++ b/test/suite0012.janet @@ -30,11 +30,11 @@ (def x (parser nil payload)) (test-http-item x expected-method expected-path expected-status expected-headers)) -(test-http-parse http/read-request "GET / HTTP/1.0\r\n\r\n" "GET" "/" nil {}) -(test-http-parse http/read-request "GET /abc.janet HTTP/1.0\r\n\r\n" "GET" "/abc.janet" nil {}) -(test-http-parse http/read-request "GET /abc.janet HTTP/1.0\r\na:b\r\n\r\n" "GET" "/abc.janet" nil {"a" "b"}) -(test-http-parse http/read-request "POST /abc.janet HTTP/1.0\r\na:b\r\n\r\nextraextra" "POST" "/abc.janet" nil {"a" "b"}) -(test-http-parse http/read-response "HTTP/1.0 200 OK\r\na:b\r\n\r\nextraextra" nil nil 200 {"a" "b"}) +(test-http-parse http/read-request @"GET / HTTP/1.0\r\n\r\n" "GET" "/" nil {}) +(test-http-parse http/read-request @"GET /abc.janet HTTP/1.0\r\n\r\n" "GET" "/abc.janet" nil {}) +(test-http-parse http/read-request @"GET /abc.janet HTTP/1.0\r\na:b\r\n\r\n" "GET" "/abc.janet" nil {"a" "b"}) +(test-http-parse http/read-request @"POST /abc.janet HTTP/1.0\r\na:b\r\n\r\nextraextra" "POST" "/abc.janet" nil {"a" "b"}) +(test-http-parse http/read-response @"HTTP/1.0 200 OK\r\na:b\r\n\r\nextraextra" nil nil 200 {"a" "b"}) (defn simple-server [req] @@ -52,20 +52,14 @@ (with [server (http/server body-server "127.0.0.1" 9816)] (def res (http/request "POST" "http://127.0.0.1:9816" :body "Strong and healthy")) - (test-http-item res nil nil 200 {"content-length" "18"}) - (assert (= (length (res :body)) 18) - "actual body length")) + (test-http-item res nil nil 200 {"content-length" "18"})) (with [server (http/server body-server "127.0.0.1" 9816)] (def res (http/request "POST" "http://127.0.0.1:9816" :body (string/repeat "a" 2097152))) - (test-http-item res nil nil 200 {"content-length" "2097152"}) - (assert (= (length (res :body)) 18) - "actual body length")) + (test-http-item res nil nil 200 {"content-length" "2097152"})) (with [server (http/server body-server "127.0.0.1" 9816)] (def res (http/request "POST" "http://127.0.0.1:9816" :body (string/repeat "a" 4194304))) - (test-http-item res nil nil 200 {"content-length" "4194304"}) - (assert (= (length (res :body)) 18) - "actual body length")) + (test-http-item res nil nil 200 {"content-length" "4194304"})) (end-suite) |
