mirror of
https://github.com/lammertb/libhttp.git
synced 2025-07-31 08:24:23 +03:00
Alternative to mg_upload (Step 15/?)
This commit is contained in:
@ -190,7 +190,7 @@ FormHandler(struct mg_connection *conn, void *cbdata)
|
|||||||
/* Handler may access the request info using mg_get_request_info */
|
/* Handler may access the request info using mg_get_request_info */
|
||||||
const struct mg_request_info *req_info = mg_get_request_info(conn);
|
const struct mg_request_info *req_info = mg_get_request_info(conn);
|
||||||
int ret;
|
int ret;
|
||||||
struct mg_form_data_handler fdh = {field_found, 0, 0};
|
struct mg_form_data_handler fdh = {field_found, 0};
|
||||||
|
|
||||||
/* TODO: Checks before calling handle_form_data ? */
|
/* TODO: Checks before calling handle_form_data ? */
|
||||||
(void)req_info;
|
(void)req_info;
|
||||||
|
@ -56,8 +56,14 @@ url_encoded_field_found(const char *key,
|
|||||||
struct mg_form_data_handler *fdh)
|
struct mg_form_data_handler *fdh)
|
||||||
{
|
{
|
||||||
/* Call callback */
|
/* Call callback */
|
||||||
/* TODO: mg_url_decode(key, (size_t)keylen, ) */
|
char key_dec[1024];
|
||||||
return fdh->field_found(key, keylen, filename, disposition, fdh->user_data);
|
int ret =
|
||||||
|
mg_url_decode(key, (size_t)keylen, key_dec, (int)sizeof(key_dec), 1);
|
||||||
|
if ((ret < sizeof(key_dec)) && (ret >= 0)) {
|
||||||
|
return fdh->field_found(
|
||||||
|
key, keylen, filename, disposition, fdh->user_data);
|
||||||
|
}
|
||||||
|
return 0; /* SKIP; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -187,7 +193,7 @@ mg_handle_form_data(struct mg_connection *conn,
|
|||||||
|
|
||||||
/* Call callback */
|
/* Call callback */
|
||||||
fdh->field_found(
|
fdh->field_found(
|
||||||
buf, (size_t)keylen, val, (size_t)vallen, fdh->user_data);
|
buf, (size_t)keylen, NULL, &disposition, fdh->user_data);
|
||||||
|
|
||||||
/* Proceed to next entry */
|
/* Proceed to next entry */
|
||||||
used = next - buf;
|
used = next - buf;
|
||||||
|
Reference in New Issue
Block a user