Add mg_http_next_part

This commit is contained in:
cpq 2021-03-15 13:20:53 +00:00
parent bcb0874477
commit bc00d5159a
4 changed files with 29 additions and 0 deletions

View File

@ -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) {

View File

@ -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,

View File

@ -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) {

View File

@ -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 *);