mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-18 10:59:45 +00:00
Add form-upload example
This commit is contained in:
1 parent
41c1e0f08d
commit
4dbb2da78f
7 files changed
+116
-36
No files matched your search
+7
-5
@@ -1265,9 +1265,9 @@ static void test_multipart(void) {
|
||||
"--xyz\r\n"
|
||||
"Content-Disposition: form-data; name=\"val\"\r\n"
|
||||
"\r\n"
|
||||
"abcdef\r\n"
|
||||
"abc\r\ndef\r\n"
|
||||
"--xyz\r\n"
|
||||
"Content-Disposition: form-data; name=\"foo\"; filename=\"a.txt\"\r\n"
|
||||
"Content-Disposition: form-data; name=\"foo\"; filename=\"a b.txt\"\r\n"
|
||||
"Content-Type: text/plain\r\n"
|
||||
"\r\n"
|
||||
"hello world\r\n"
|
||||
@@ -1276,12 +1276,14 @@ static void test_multipart(void) {
|
||||
ASSERT(mg_http_next_multipart(mg_str(""), 0, NULL) == 0);
|
||||
ASSERT((ofs = mg_http_next_multipart(mg_str(s), 0, &part)) > 0);
|
||||
ASSERT(mg_strcmp(part.name, mg_str("val")) == 0);
|
||||
ASSERT(mg_strcmp(part.body, mg_str("abcdef")) == 0);
|
||||
// LOG(LL_INFO, ("--> [%.*s]", (int) part.body.len, part.body.ptr));
|
||||
ASSERT(mg_strcmp(part.body, mg_str("abc\r\ndef")) == 0);
|
||||
ASSERT(part.filename.len == 0);
|
||||
ASSERT((ofs = mg_http_next_multipart(mg_str(s), ofs, &part)) > 0);
|
||||
ASSERT(mg_strcmp(part.name, mg_str("foo")) == 0);
|
||||
ASSERT(mg_strcmp(part.filename, mg_str("a.txt")) == 0);
|
||||
ASSERT(mg_strcmp(part.body, mg_str("hello world")) == 0);
|
||||
// LOG(LL_INFO, ("--> [%.*s]", (int) part.filename.len, part.filename.ptr));
|
||||
ASSERT(mg_strcmp(part.filename, mg_str("a b.txt")) == 0);
|
||||
ASSERT(mg_strcmp(part.body, mg_str("hello world\r\n")) == 0);
|
||||
ASSERT(mg_http_next_multipart(mg_str(s), ofs, &part) == 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user