From bc00d5159abafa53afb024999c624ab55df63111 Mon Sep 17 00:00:00 2001 From: cpq Date: Mon, 15 Mar 2021 13:20:53 +0000 Subject: [PATCH] Add mg_http_next_part --- mongoose.c | 6 ++++++ mongoose.h | 8 ++++++++ src/http.c | 7 +++++++ src/http.h | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/mongoose.c b/mongoose.c index 44bf6d51..9ebe2862 100644 --- a/mongoose.c +++ b/mongoose.c @@ -430,6 +430,12 @@ void mg_error(struct mg_connection *c, const char *fmt, ...) { // Multipart POST example: // https://gist.github.com/cpq/b8dd247571e6ee9c54ef7e8dfcfecf48 +int mg_http_next_multipart(struct mg_str body, int offset, + struct mg_http_part *part) { + (void) body; + (void) part; + return offset; +} void mg_http_bauth(struct mg_connection *c, const char *user, const char *pass) { diff --git a/mongoose.h b/mongoose.h index d60f91ab..9cd9ed19 100644 --- a/mongoose.h +++ b/mongoose.h @@ -748,6 +748,13 @@ struct mg_http_serve_opts { const char *extra_headers; // Extra HTTP headers to add in responses }; +// Parameter for mg_http_next_multipart +struct mg_http_part { + struct mg_str name; // Form field name + struct mg_str filename; // Filename for file uploads + struct mg_str part; // Part contents +}; + int mg_http_parse(const char *s, size_t len, struct mg_http_message *); int mg_http_get_request_len(const unsigned char *buf, size_t buf_len); void mg_http_printf_chunk(struct mg_connection *cnn, const char *fmt, ...); @@ -773,6 +780,7 @@ bool mg_http_match_uri(const struct mg_http_message *, const char *glob); int mg_http_upload(struct mg_connection *, struct mg_http_message *hm, const char *dir); void mg_http_bauth(struct mg_connection *, const char *user, const char *pass); +int mg_http_next_multipart(struct mg_str, int, struct mg_http_part *); void mg_http_serve_ssi(struct mg_connection *c, const char *root, diff --git a/src/http.c b/src/http.c index 8660a899..38fef6d9 100644 --- a/src/http.c +++ b/src/http.c @@ -11,6 +11,13 @@ // Multipart POST example: // https://gist.github.com/cpq/b8dd247571e6ee9c54ef7e8dfcfecf48 +int mg_http_next_multipart(struct mg_str body, int offset, + struct mg_http_part *part) { + if (o + (void) body; + (void) part; + return 0; +} void mg_http_bauth(struct mg_connection *c, const char *user, const char *pass) { diff --git a/src/http.h b/src/http.h index c7efa525..b74595a9 100644 --- a/src/http.h +++ b/src/http.h @@ -28,6 +28,13 @@ struct mg_http_serve_opts { const char *extra_headers; // Extra HTTP headers to add in responses }; +// Parameter for mg_http_next_multipart +struct mg_http_part { + struct mg_str name; // Form field name + struct mg_str filename; // Filename for file uploads + struct mg_str part; // Part contents +}; + int mg_http_parse(const char *s, size_t len, struct mg_http_message *); int mg_http_get_request_len(const unsigned char *buf, size_t buf_len); void mg_http_printf_chunk(struct mg_connection *cnn, const char *fmt, ...); @@ -53,3 +60,4 @@ bool mg_http_match_uri(const struct mg_http_message *, const char *glob); int mg_http_upload(struct mg_connection *, struct mg_http_message *hm, const char *dir); void mg_http_bauth(struct mg_connection *, const char *user, const char *pass); +int mg_http_next_multipart(struct mg_str, int, struct mg_http_part *);