Not support parse chunked body from client
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>main
parent
2eb72631bb
commit
34bbc9264f
36
src/client.c
36
src/client.c
|
@ -269,8 +269,6 @@ static void client_poll_post_data(struct uh_client *cl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
char *sep;
|
|
||||||
int offset = 0;
|
|
||||||
int cur_len;
|
int cur_len;
|
||||||
|
|
||||||
buf = ustream_get_read_buf(cl->us, &len);
|
buf = ustream_get_read_buf(cl->us, &len);
|
||||||
|
@ -289,38 +287,9 @@ static void client_poll_post_data(struct uh_client *cl)
|
||||||
ustream_consume(cl->us, cur_len);
|
ustream_consume(cl->us, cur_len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!r->transfer_chunked)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (r->transfer_chunked > 1)
|
|
||||||
offset = 2;
|
|
||||||
|
|
||||||
sep = strstr(buf + offset, "\r\n");
|
|
||||||
if (!sep)
|
|
||||||
break;
|
|
||||||
|
|
||||||
*sep = 0;
|
|
||||||
|
|
||||||
r->content_length = strtoul(buf + offset, &sep, 16);
|
|
||||||
r->transfer_chunked++;
|
|
||||||
ustream_consume(cl->us, sep + 2 - buf);
|
|
||||||
|
|
||||||
/* invalid chunk length */
|
|
||||||
if (sep && *sep) {
|
|
||||||
r->content_length = 0;
|
|
||||||
r->transfer_chunked = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* empty chunk == eof */
|
|
||||||
if (!r->content_length) {
|
|
||||||
r->transfer_chunked = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!r->content_length && !r->transfer_chunked && cl->state != CLIENT_STATE_DONE) {
|
if (!r->content_length && cl->state != CLIENT_STATE_DONE) {
|
||||||
if (cl->dispatch.data_done)
|
if (cl->dispatch.data_done)
|
||||||
cl->dispatch.data_done(cl);
|
cl->dispatch.data_done(cl);
|
||||||
|
|
||||||
|
@ -365,7 +334,8 @@ static void client_parse_header(struct uh_client *cl, char *data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(data, "transfer-encoding") && !strcmp(val, "chunked")) {
|
} else if (!strcmp(data, "transfer-encoding") && !strcmp(val, "chunked")) {
|
||||||
r->transfer_chunked = true;
|
cl->send_error(cl, 501, "Not Implemented", "Chunked body is not implemented");
|
||||||
|
return;
|
||||||
} else if (!strcmp(data, "connection") && !strcasecmp(val, "close")) {
|
} else if (!strcmp(data, "connection") && !strcasecmp(val, "close")) {
|
||||||
cl->connection_close = true;
|
cl->connection_close = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ struct http_request {
|
||||||
enum http_method method;
|
enum http_method method;
|
||||||
enum http_version version;
|
enum http_version version;
|
||||||
int content_length;
|
int content_length;
|
||||||
bool transfer_chunked;
|
|
||||||
bool chunked;
|
bool chunked;
|
||||||
struct kvlist hdr;
|
struct kvlist hdr;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue