X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fhttp_test.c;h=43bace2253970fb9f07ceac5237fedff18b0cb9c;hb=540dc81aaba32706787f118b9ae05153103f7902;hp=288282774d46bc6dbe3912add57ac58a3f545b09;hpb=470f5cb37d5adce8fa5efd0092b2885528d7fb32;p=bertos.git diff --git a/bertos/net/http_test.c b/bertos/net/http_test.c index 28828277..43bace22 100644 --- a/bertos/net/http_test.c +++ b/bertos/net/http_test.c @@ -72,6 +72,9 @@ q=0.6,en;q=0.4 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3"; static const char uri[] = "test%5B%5D!@;'%22%5C.%20"; static const char uri_check[] = "test[]!@;'\"\\. "; +static const char uri0[] = "12345"; +static const char uri_check0[] = "1234"; + static const char uri1[] = "!*'();:@&=%2B%24%2C/?#%5B%5D%3C%3E%7E.%22%7B%7D%7C%5C-%60_%5E%25"; static const char uri_check1[] = "!*'();:@&=+$,/?#[]<>~.\"{}|\\-`_^%"; @@ -82,6 +85,34 @@ static char token_str[] = "var1=1&var2=2&var3=3&var4=4"; static char token_str1[] = "var1=1&var2=2&=3&var4="; static char token_str2[] = "var1=test+test&var2=2&var3=test%5B%5D!@;'%22%5C.%20&var4=4"; +static struct {const char *content;} contents[] = +{ + {"one/two/three/test"}, + {"one/two/three.htm"}, + {"one/test.css"}, + {"one/two/test.js"}, + {"one/two/test.png"}, + {"one/two/test.ico"}, + {"one/two/test.jpg"}, + {"one/two/test.gif"}, +}; + + +static int contents_check_type[] = +{ + HTTP_CONTENT_JSON, + HTTP_CONTENT_HTML, + HTTP_CONTENT_CSS, + HTTP_CONTENT_JS, + HTTP_CONTENT_PNG, + HTTP_CONTENT_JPEG, + HTTP_CONTENT_JPEG, + HTTP_CONTENT_GIF, +}; + +#define CONTENT_TEST_CNT 8 + + int http_testSetup(void) { kdbg_init(); @@ -127,6 +158,15 @@ int http_testRun(void) } + char decoded0[5]; + http_decodeUrl(uri0, 6, decoded0, 5); + + if (strcmp(decoded0, uri_check0)) + { + kprintf("error 04 %s\n", decoded0); + goto error; + } + char decoded[sizeof(uri)]; http_decodeUrl(uri,sizeof(uri), decoded, sizeof(uri)); @@ -243,6 +283,18 @@ int http_testRun(void) } + + for (int i = 0; i < CONTENT_TEST_CNT; i++) + { + int type = http_searchContentType(contents[i].content); + if (type != contents_check_type[i]) + { + kprintf("error 8-%d return type %d expect %d\n", i, type, contents_check_type[i]); + kprintf("error 8-%d ext %s\n", i, contents[i].content); + goto error; + } + } + return 0; error: