122struct MHD_PostProcessor
144 const char *encoding;
149 const char *boundary;
154 char *nested_boundary;
169 char *content_filename;
174 char *content_transfer_encoding;
225 bool must_unescape_key;
255struct MHD_PostProcessor *
261 struct MHD_PostProcessor *
ret;
262 const char *encoding;
263 const char *boundary;
266 if ( (buffer_size < 256) ||
267 (
NULL == connection) ||
295 boundary =
strstr (boundary,
"boundary=");
296 if (
NULL == boundary)
301 (blen * 2 + 2 > buffer_size) )
303 if ( (boundary[0] ==
'"') &&
304 (boundary[blen - 1] ==
'"') )
319 ret->connection = connection;
322 ret->encoding = encoding;
323 ret->buffer_size = buffer_size;
326 ret->boundary = boundary;
364 if (0 !=
pp->xbuf_pos)
402 (
'%' == xbuf[
xoff - 1]) )
419 else if ( (
xoff > 1) &&
420 (
'%' == xbuf[
xoff - 2]) )
448 if (
pp->must_ikvi || (0 !=
xoff) )
450 pp->must_ikvi =
false;
453 (
const char *) &
pp[1],
493 char *
kbuf = (
char *) &
pp[1];
542 pp->must_ikvi =
true;
608 pp->value_offset = 0;
669 if ( (
pp->buffer_pos +
key_len >=
pp->buffer_size) ||
683 pp->must_unescape_key =
true;
690 if (
pp->must_unescape_key)
692 kbuf[
pp->buffer_pos] =
'\0';
695 pp->must_unescape_key =
false;
703 pp->value_offset = 0;
745 pp->must_unescape_key =
true;
753 if (
pp->must_unescape_key)
755 kbuf[
pp->buffer_pos] =
'\0';
758 pp->must_unescape_key =
false;
769 pp->must_ikvi =
false;
828 const char *boundary,
834 char *
buf = (
char *) &
pp[1];
837 if (
pp->buffer_pos < 2 + blen)
839 if (
pp->buffer_pos ==
pp->buffer_size)
863 (*ioffptr) +=
pp->buffer_pos;
872 (*ioffptr) += 2 + blen;
906 (
spos[-1] !=
' ') ) )
921 (*destination)[
vlen - 1] =
'\0';
950 char *
buf = (
char *) &
pp[1];
985 &
pp->content_filename);
996 &
pp->content_transfer_encoding);
1022 const char *boundary,
1027 char *
buf = (
char *) &
pp[1];
1047 if (0 ==
memcmp (
"\r\n--",
1053 if (
newline + blen + 4 <=
pp->buffer_pos)
1071 (*ioffptr) += blen + 4;
1082 (
pp->buffer_pos ==
pp->buffer_size) )
1093 if ( ( (
pp->must_ikvi) ||
1098 pp->content_filename,
1100 pp->content_transfer_encoding,
1108 pp->must_ikvi =
false;
1122 if ( (
NULL !=
pp->content_name) &&
1125 free (
pp->content_name);
1128 if ( (
NULL !=
pp->content_type) &&
1131 free (
pp->content_type);
1134 if ( (
NULL !=
pp->content_filename) &&
1137 free (
pp->content_filename);
1138 pp->content_filename =
NULL;
1140 if ( (
NULL !=
pp->content_transfer_encoding) &&
1143 free (
pp->content_transfer_encoding);
1144 pp->content_transfer_encoding =
NULL;
1168 buf = (
char *) &
pp[1];
1173 ( (
pp->buffer_pos > 0) &&
1178 max =
pp->buffer_size -
pp->buffer_pos;
1185 pp->buffer_pos += max;
1196 switch (
pp->skip_rn)
1220 if ( (
pp->buffer_pos > 1) &&
1247 pp->state =
pp->dash_state;
1296 pp->must_ikvi =
true;
1310 if ( (
NULL !=
pp->content_type) &&
1315 pp->nested_boundary =
strstr (
pp->content_type,
1317 if (
NULL ==
pp->nested_boundary)
1322 pp->nested_boundary =
1324 if (
NULL ==
pp->nested_boundary)
1332 free (
pp->content_type);
1340 pp->value_offset = 0;
1360 if (
NULL !=
pp->nested_boundary)
1362 free (
pp->nested_boundary);
1363 pp->nested_boundary =
NULL;
1369 if (
NULL ==
pp->nested_boundary)
1375 pp->nested_boundary,
1390 if (
NULL !=
pp->content_name)
1392 if (
NULL !=
pp->content_type)
1394 if (
NULL !=
pp->content_filename)
1396 if (
NULL !=
pp->content_transfer_encoding)
1402 pp->value_offset = 0;
1418 pp->nested_boundary,
1514 if ( (
pp->xbuf_pos > 0) ||
1522 if (
NULL !=
pp->nested_boundary)
1523 free (
pp->nested_boundary);
#define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA
#define MHD_HTTP_POST_ENCODING_FORM_URLENCODED
enum MHD_Result MHD_destroy_post_processor(struct MHD_PostProcessor *pp)
enum MHD_Result MHD_post_process(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
struct MHD_PostProcessor * MHD_create_post_processor(struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls)
_MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr)
void MHD_unescape_plus(char *arg)
MHD_PanicCallback mhd_panic
void * MHD_calloc_(size_t nelem, size_t elsize)
int MHD_str_equal_caseless_n_(const char *const str1, const char *const str2, size_t maxlen)
#define MHD_STATICSTR_LEN_(macro)
MHD internal shared structures.
Header for platform missing functions.
Header for string manipulating helpers.
_MHD_EXTERN size_t MHD_http_unescape(char *val)
enum MHD_Result(* MHD_PostDataIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size)
static enum MHD_Result post_process_multipart(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
static int try_match_header(const char *prefix, size_t prefix_len, char *line, char **suffix)
static int find_boundary(struct MHD_PostProcessor *pp, const char *boundary, size_t blen, size_t *ioffptr, enum PP_State next_state, enum PP_State next_dash_state)
static int process_value_to_boundary(struct MHD_PostProcessor *pp, size_t *ioffptr, const char *boundary, size_t blen, enum PP_State next_state, enum PP_State next_dash_state)
@ NE_content_transfer_encoding
static void process_value(struct MHD_PostProcessor *pp, const char *value_start, const char *value_end, const char *last_escape)
@ PP_Nested_PerformMarking
@ PP_PerformCheckMultipart
@ PP_Nested_ProcessEntryHeaders
@ PP_Nested_PerformCleanup
@ PP_ProcessValueToBoundary
@ PP_Nested_ProcessValueToBoundary
static void try_get_value(const char *buf, const char *key, char **destination)
static enum MHD_Result post_process_urlencoded(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
static void free_unmarked(struct MHD_PostProcessor *pp)
static int process_multipart_headers(struct MHD_PostProcessor *pp, size_t *ioffptr, enum PP_State next_state)
enum MHD_CONNECTION_STATE state