1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

spa: determine final boundary

By itself the HTTP layer can track transaction sizes only with
content-length, including on POST.

However it's also possible for whatever logically interprets
the payload to determine its length, for example with multipart,
the multipart headers can do that job.

This allows the spa stuff to drive the content length tracking,
so lws can interpret multipart POST client payload without needing
an overall content-length.
This commit is contained in:
Andy Green 2018-04-03 10:08:21 +08:00
parent 2a9b6f54c6
commit 419a6af38d

View file

@ -35,6 +35,8 @@ enum urldecode_stateful {
MT_TYPE,
MT_IGNORE1,
MT_IGNORE2,
MT_IGNORE3,
MT_COMPLETED,
};
static const char * const mp_hdr[] = {
@ -49,6 +51,7 @@ typedef int (*lws_urldecode_stateful_cb)(void *data,
struct lws_urldecode_stateful {
char *out;
void *data;
struct lws *wsi;
char name[LWS_MAX_ELEM_NAME];
char temp[LWS_MAX_ELEM_NAME];
char content_type[32];
@ -92,6 +95,7 @@ lws_urldecode_s_create(struct lws *wsi, char *out, int out_len, void *data,
s->state = US_NAME;
s->name[0] = '\0';
s->data = data;
s->wsi = wsi;
if (lws_hdr_copy(wsi, buf, sizeof(buf),
WSI_TOKEN_HTTP_CONTENT_TYPE) > 0) {
@ -363,6 +367,8 @@ done:
case MT_IGNORE1:
if (*in == '\x0d')
s->state = MT_IGNORE2;
if (*in == '-')
s->state = MT_IGNORE3;
in++;
break;
@ -372,6 +378,18 @@ done:
s->state = MT_HNAME;
in++;
break;
case MT_IGNORE3:
if (*in == '\x0d')
s->state = MT_IGNORE1;
if (*in == '-') {
s->state = MT_COMPLETED;
s->wsi->http.rx_content_remain = 0;
}
in++;
break;
case MT_COMPLETED:
break;
}
}