mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
CLEANUP: http: prepare dedicated processing for chunked encoded message bodies
Content-length encoded message bodies are trivial to deal with, but chunked-encoded will require improvements, so let's separate the code flows between the two to ease next steps. The behaviour is not changed at all, the code is only rearranged.
This commit is contained in:
parent
5a8f947f4f
commit
890988f122
@ -4298,7 +4298,9 @@ int http_wait_for_request_body(struct session *s, struct channel *req, int an_bi
|
||||
* related structures are ready.
|
||||
*/
|
||||
|
||||
if (unlikely(msg->msg_state < HTTP_MSG_BODY))
|
||||
if (msg->msg_state < HTTP_MSG_CHUNK_SIZE) {
|
||||
/* This is the first call */
|
||||
if (msg->msg_state < HTTP_MSG_BODY)
|
||||
goto missing_data;
|
||||
|
||||
if (msg->msg_state < HTTP_MSG_100_SENT) {
|
||||
@ -4317,7 +4319,6 @@ int http_wait_for_request_body(struct session *s, struct channel *req, int an_bi
|
||||
msg->msg_state = HTTP_MSG_100_SENT;
|
||||
}
|
||||
|
||||
if (msg->msg_state < HTTP_MSG_CHUNK_SIZE) {
|
||||
/* we have msg->sov which points to the first byte of message body.
|
||||
* req->buf->p still points to the beginning of the message and msg->sol
|
||||
* is still null. We must save the body in msg->next because it
|
||||
@ -4331,6 +4332,17 @@ int http_wait_for_request_body(struct session *s, struct channel *req, int an_bi
|
||||
msg->msg_state = HTTP_MSG_DATA;
|
||||
}
|
||||
|
||||
if (!(msg->flags & HTTP_MSGF_TE_CHNK)) {
|
||||
/* We're in content-length mode, we just have to wait for enough data. */
|
||||
if (req->buf->i - msg->sov < msg->body_len)
|
||||
goto missing_data;
|
||||
|
||||
/* OK we have everything we need now */
|
||||
goto http_end;
|
||||
}
|
||||
|
||||
/* OK here we're parsing a chunked-encoded message */
|
||||
|
||||
if (msg->msg_state == HTTP_MSG_CHUNK_SIZE) {
|
||||
/* read the chunk size and assign it to ->chunk_len, then
|
||||
* set ->sov and ->next to point to the body and switch to DATA or
|
||||
@ -4350,6 +4362,9 @@ int http_wait_for_request_body(struct session *s, struct channel *req, int an_bi
|
||||
* We have the first data byte is in msg->sov. We're waiting for at
|
||||
* least a whole chunk or the whole content length bytes after msg->sov.
|
||||
*/
|
||||
if (msg->msg_state == HTTP_MSG_TRAILERS)
|
||||
goto http_end;
|
||||
|
||||
if (req->buf->i - msg->sov >= msg->body_len) /* we have enough bytes now */
|
||||
goto http_end;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user