about summary refs log tree commit homepage
path: root/test/http-parser-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/http-parser-1.c')
-rw-r--r--test/http-parser-1.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/http-parser-1.c b/test/http-parser-1.c
index 9125b9c..f699611 100644
--- a/test/http-parser-1.c
+++ b/test/http-parser-1.c
@@ -41,6 +41,7 @@ int main(void)
                 assert(http->_p.persistent && "not persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("normal HTTP GET request with redundant leading slash") {
@@ -51,6 +52,7 @@ int main(void)
                 assert(http->_p.persistent && "not persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 request with explicit close") {
@@ -64,6 +66,7 @@ int main(void)
                 assert(http->_p.persistent == 0 && "should not be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.0 request with keepalive") {
@@ -76,6 +79,7 @@ int main(void)
                 assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("bogus HTTP/1.0 request") {
@@ -84,6 +88,7 @@ int main(void)
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
                 assert(state == MOG_PARSER_ERROR && "parser not errored");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("bogus request") {
@@ -92,6 +97,7 @@ int main(void)
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
                 assert(state == MOG_PARSER_ERROR && "parser not errored");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 HEAD request") {
@@ -104,6 +110,7 @@ int main(void)
                 assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 PUT request") {
@@ -121,6 +128,7 @@ int main(void)
                 assert_path_equal("/foo");
                 assert(strcmp(buf + http->_p.buf_off, "partial body request")
                        == 0 && "buffer repositioned to body start");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 PUT chunked request header") {
@@ -139,6 +147,7 @@ int main(void)
                 assert_path_equal("/foo");
                 assert(strcmp(buf + http->_p.buf_off, "16\r\npartial...") == 0
                        && "buffer repositioned to body start");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 PUT with Content-Range") {
@@ -160,6 +169,7 @@ int main(void)
                 assert_path_equal("/foo");
                 assert(strcmp(buf + http->_p.buf_off, "16\r\npartial...") == 0
                        && "buffer repositioned to body start");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 PUT chunked request header w/Trailer") {
@@ -179,6 +189,7 @@ int main(void)
                 assert_path_equal("/foo");
                 assert(strcmp(buf + http->_p.buf_off, "16\r\npartial...") == 0
                        && "buffer repositioned to body start");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 DELETE request") {
@@ -193,6 +204,7 @@ int main(void)
                 assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 MKCOL request") {
@@ -207,6 +219,7 @@ int main(void)
                 assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 Range (mid) GET request") {
@@ -223,6 +236,7 @@ int main(void)
                 assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 Range (tip) GET request") {
@@ -239,6 +253,7 @@ int main(void)
                 assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 Range (end) GET request") {
@@ -255,6 +270,7 @@ int main(void)
                 assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
+                assert(!http->_p.usage_txt && "not a usage request");
         }
 
         if ("HTTP/1.1 devid parse") {
@@ -266,6 +282,25 @@ int main(void)
                 assert(http->_p.mog_devid == 666 && "dev666 set");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/dev666/0/1.fid");
+                assert(!http->_p.usage_txt && "not a usage request");
+        }
+
+        if ("HTTP/1.0 devN/usage request") {
+                buf_set("GET /dev666/usage HTTP/1.0\r\n\r\n");
+                state = mog_http_parse(http, buf, len);
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
+                       && "http_method should be GET");
+                assert(http->_p.mog_devid == 666 && "dev666 set");
+                assert(state == MOG_PARSER_DONE && "parser not done");
+                assert(http->_p.usage_txt && "a usage request");
+
+                buf_set("GET /dev666/usager HTTP/1.0\r\n\r\n");
+                state = mog_http_parse(http, buf, len);
+                assert(!http->_p.usage_txt && "a usage request");
+
+                buf_set("GET /dev666/usag HTTP/1.0\r\n\r\n");
+                state = mog_http_parse(http, buf, len);
+                assert(!http->_p.usage_txt && "a usage request");
         }
 
         reset();