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.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/test/http-parser-1.c b/test/http-parser-1.c
index 688e0a5..861c19f 100644
--- a/test/http-parser-1.c
+++ b/test/http-parser-1.c
@@ -14,8 +14,8 @@ static void assert_path_equal(const char *str)
 {
         size_t slen = strlen(str);
 
-        assert(0 == memcmp(str, buf + http->path_tip, slen));
-        assert(http->path_end == http->path_tip + slen);
+        assert(0 == memcmp(str, buf + http->_p.path_tip, slen));
+        assert(http->_p.path_end == http->_p.path_tip + slen);
 }
 
 static void reset(void)
@@ -36,9 +36,9 @@ int main(void)
         if ("normal HTTP GET request") {
                 buf_set("GET /foo HTTP/1.1\r\nHost: 127.6.6.6\r\n\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->http_method == MOG_HTTP_METHOD_GET
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
                        && "http_method should be GET");
-                assert(http->persistent && "not persistent");
+                assert(http->_p.persistent && "not persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -46,9 +46,9 @@ int main(void)
         if ("normal HTTP GET request with redundant leading slash") {
                 buf_set("GET //foo HTTP/1.1\r\nHost: 127.6.6.6\r\n\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->http_method == MOG_HTTP_METHOD_GET
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
                        && "http_method should be GET");
-                assert(http->persistent && "not persistent");
+                assert(http->_p.persistent && "not persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -59,9 +59,9 @@ int main(void)
                         "Connection: close\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->http_method == MOG_HTTP_METHOD_GET
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
                        && "http_method should be GET");
-                assert(http->persistent == 0 && "should not be persistent");
+                assert(http->_p.persistent == 0 && "should not be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -71,9 +71,9 @@ int main(void)
                         "Connection:\r\n keep-alive\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->http_method == MOG_HTTP_METHOD_GET
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
                        && "http_method should be GET");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -99,9 +99,9 @@ int main(void)
                         "Host: 127.6.6.6\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->http_method == MOG_HTTP_METHOD_HEAD
+                assert(http->_p.http_method == MOG_HTTP_METHOD_HEAD
                        && "http_method should be HEAD ");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -113,13 +113,13 @@ int main(void)
                         "\r\n"
                         "partial body request");
                 state = mog_http_parse(http, buf, len);
-                assert(http->content_len == 12345);
-                assert(http->http_method == MOG_HTTP_METHOD_PUT
+                assert(http->_p.content_len == 12345);
+                assert(http->_p.http_method == MOG_HTTP_METHOD_PUT
                        && "http_method should be PUT");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
-                assert(strcmp(buf + http->offset, "partial body request") == 0
+                assert(strcmp(buf + http->_p.offset, "partial body request") == 0
                        && "buffer repositioned to body start");
         }
 
@@ -130,14 +130,14 @@ int main(void)
                         "\r\n"
                         "16\r\npartial...");
                 state = mog_http_parse(http, buf, len);
-                assert(http->chunked);
-                assert(http->has_trailer_md5 == 0);
-                assert(http->http_method == MOG_HTTP_METHOD_PUT
+                assert(http->_p.chunked);
+                assert(http->_p.has_trailer_md5 == 0);
+                assert(http->_p.http_method == MOG_HTTP_METHOD_PUT
                        && "http_method should be PUT");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
-                assert(strcmp(buf + http->offset, "16\r\npartial...") == 0
+                assert(strcmp(buf + http->_p.offset, "16\r\npartial...") == 0
                        && "buffer repositioned to body start");
         }
 
@@ -149,16 +149,16 @@ int main(void)
                         "\r\n"
                         "16\r\npartial...");
                 state = mog_http_parse(http, buf, len);
-                assert(http->range_beg == 666);
-                assert(http->range_end == 666666);
-                assert(http->has_content_range == 1);
-                assert(http->has_trailer_md5 == 0);
-                assert(http->http_method == MOG_HTTP_METHOD_PUT
+                assert(http->_p.range_beg == 666);
+                assert(http->_p.range_end == 666666);
+                assert(http->_p.has_content_range == 1);
+                assert(http->_p.has_trailer_md5 == 0);
+                assert(http->_p.http_method == MOG_HTTP_METHOD_PUT
                        && "http_method should be PUT");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
-                assert(strcmp(buf + http->offset, "16\r\npartial...") == 0
+                assert(strcmp(buf + http->_p.offset, "16\r\npartial...") == 0
                        && "buffer repositioned to body start");
         }
 
@@ -170,14 +170,14 @@ int main(void)
                         "\r\n"
                         "16\r\npartial...");
                 state = mog_http_parse(http, buf, len);
-                assert(http->chunked);
-                assert(http->has_trailer_md5 == 1);
-                assert(http->http_method == MOG_HTTP_METHOD_PUT
+                assert(http->_p.chunked);
+                assert(http->_p.has_trailer_md5 == 1);
+                assert(http->_p.http_method == MOG_HTTP_METHOD_PUT
                        && "http_method should be PUT");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
-                assert(strcmp(buf + http->offset, "16\r\npartial...") == 0
+                assert(strcmp(buf + http->_p.offset, "16\r\npartial...") == 0
                        && "buffer repositioned to body start");
         }
 
@@ -186,11 +186,11 @@ int main(void)
                         "Host: 127.6.6.6\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->content_len == 0);
-                assert(http->has_trailer_md5 == 0);
-                assert(http->http_method == MOG_HTTP_METHOD_DELETE
+                assert(http->_p.content_len == 0);
+                assert(http->_p.has_trailer_md5 == 0);
+                assert(http->_p.http_method == MOG_HTTP_METHOD_DELETE
                        && "http_method should be DELETE");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -200,11 +200,11 @@ int main(void)
                         "Host: 127.6.6.6\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->content_len == 0);
-                assert(http->has_trailer_md5 == 0);
-                assert(http->http_method == MOG_HTTP_METHOD_MKCOL
+                assert(http->_p.content_len == 0);
+                assert(http->_p.has_trailer_md5 == 0);
+                assert(http->_p.http_method == MOG_HTTP_METHOD_MKCOL
                        && "http_method should be MKCOL");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -215,12 +215,12 @@ int main(void)
                         "Range: bytes=5-55\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->has_range == 1);
-                assert(http->range_beg == 5 && "range_beg didn't match");
-                assert(http->range_end == 55 && "range_end didn't match");
-                assert(http->http_method == MOG_HTTP_METHOD_GET
+                assert(http->_p.has_range == 1);
+                assert(http->_p.range_beg == 5 && "range_beg didn't match");
+                assert(http->_p.range_end == 55 && "range_end didn't match");
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
                        && "http_method should be GET");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -231,12 +231,12 @@ int main(void)
                         "Range: bytes=-55\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->has_range == 1);
-                assert(http->range_beg == -1 && "range_beg didn't match");
-                assert(http->range_end == 55 && "range_end didn't match");
-                assert(http->http_method == MOG_HTTP_METHOD_GET
+                assert(http->_p.has_range == 1);
+                assert(http->_p.range_beg == -1 && "range_beg didn't match");
+                assert(http->_p.range_end == 55 && "range_end didn't match");
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
                        && "http_method should be GET");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }
@@ -247,12 +247,12 @@ int main(void)
                         "Range: bytes=55-\r\n"
                         "\r\n");
                 state = mog_http_parse(http, buf, len);
-                assert(http->has_range == 1);
-                assert(http->range_beg == 55 && "range_beg didn't match");
-                assert(http->range_end == -1 && "range_end didn't match");
-                assert(http->http_method == MOG_HTTP_METHOD_GET
+                assert(http->_p.has_range == 1);
+                assert(http->_p.range_beg == 55 && "range_beg didn't match");
+                assert(http->_p.range_end == -1 && "range_end didn't match");
+                assert(http->_p.http_method == MOG_HTTP_METHOD_GET
                        && "http_method should be GET");
-                assert(http->persistent == 1 && "should be persistent");
+                assert(http->_p.persistent == 1 && "should be persistent");
                 assert(state == MOG_PARSER_DONE && "parser not done");
                 assert_path_equal("/foo");
         }