mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
Add mg_http_next_multipart()
This commit is contained in:
1 parent
bc00d5159a
commit
5bd22cb5e4
6 files changed
+211
-35
No files matched your search
@@ -1258,9 +1258,37 @@ static void test_http_chunked(void) {
|
||||
ASSERT(mgr.conns == NULL);
|
||||
}
|
||||
|
||||
static void test_multipart(void) {
|
||||
struct mg_http_part part;
|
||||
size_t ofs;
|
||||
const char *s =
|
||||
"--xyz\r\n"
|
||||
"Content-Disposition: form-data; name=\"val\"\r\n"
|
||||
"\r\n"
|
||||
"abcdef\r\n"
|
||||
"--xyz\r\n"
|
||||
"Content-Disposition: form-data; name=\"foo\"; filename=\"a.txt\"\r\n"
|
||||
"Content-Type: text/plain\r\n"
|
||||
"\r\n"
|
||||
"hello world\r\n"
|
||||
"\r\n"
|
||||
"--xyz--\r\n";
|
||||
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);
|
||||
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);
|
||||
ASSERT(mg_http_next_multipart(mg_str(s), ofs, &part) == 0);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
mg_log_set("3");
|
||||
test_crc32();
|
||||
test_multipart();
|
||||
test_http_chunked();
|
||||
test_http_parse();
|
||||
test_util();
|
||||
|
||||
Reference in new issue
Block a user