CLEANUP: http: rename HTTP_MSG_DATA_CRLF state
This state's name is confusing as it is only used with chunked encoding
and makes newcomers think it's also related to the content-length. Let's
call it CHUNK_CRLF to clear any doubt on this.
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index 2e3b80b..4db7882 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -166,7 +166,7 @@
#define HTTP_MSG_100_SENT 28 // parsing body after a 100-Continue was sent
#define HTTP_MSG_CHUNK_SIZE 29 // parsing the chunk size (RFC2616 #3.6.1)
#define HTTP_MSG_DATA 30 // skipping data chunk / content-length data
-#define HTTP_MSG_DATA_CRLF 31 // skipping CRLF after data chunk
+#define HTTP_MSG_CHUNK_CRLF 31 // skipping CRLF after data chunk
#define HTTP_MSG_TRAILERS 32 // trailers (post-data entity headers)
/* we enter this state when we've received the end of the current message */
diff --git a/src/proto_http.c b/src/proto_http.c
index 0c812d9..4377573 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -1919,7 +1919,7 @@
}
}
-/* This function may be called only in HTTP_MSG_DATA_CRLF. It reads the CRLF or
+/* This function may be called only in HTTP_MSG_CHUNK_CRLF. It reads the CRLF or
* a possible LF alone at the end of a chunk. It automatically adjusts msg->sov,
* ->sol, ->next in order to include this part into the next forwarding phase.
* Note that the caller must ensure that ->p points to the first byte to parse.
@@ -4318,9 +4318,8 @@
if (msg->flags & HTTP_MSGF_TE_CHNK)
msg->msg_state = HTTP_MSG_CHUNK_SIZE;
- else {
+ else
msg->msg_state = HTTP_MSG_DATA;
- }
}
while (1) {
@@ -4343,7 +4342,7 @@
/* nothing left to forward */
if (msg->flags & HTTP_MSGF_TE_CHNK)
- msg->msg_state = HTTP_MSG_DATA_CRLF;
+ msg->msg_state = HTTP_MSG_CHUNK_CRLF;
else
msg->msg_state = HTTP_MSG_DONE;
}
@@ -4354,7 +4353,7 @@
*/
int ret = http_parse_chunk_size(msg);
- if (!ret)
+ if (ret == 0)
goto missing_data;
else if (ret < 0) {
session_inc_http_err_ctr(s);
@@ -4364,18 +4363,16 @@
}
/* otherwise we're in HTTP_MSG_DATA or HTTP_MSG_TRAILERS state */
}
- else if (msg->msg_state == HTTP_MSG_DATA_CRLF) {
+ else if (msg->msg_state == HTTP_MSG_CHUNK_CRLF) {
/* we want the CRLF after the data */
- int ret;
-
- ret = http_skip_chunk_crlf(msg);
+ int ret = http_skip_chunk_crlf(msg);
if (ret == 0)
goto missing_data;
else if (ret < 0) {
session_inc_http_err_ctr(s);
if (msg->err_pos >= 0)
- http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_DATA_CRLF, s->be);
+ http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_CHUNK_CRLF, s->be);
goto return_bad_req;
}
/* we're in MSG_CHUNK_SIZE now */
@@ -5381,9 +5378,8 @@
if (msg->flags & HTTP_MSGF_TE_CHNK)
msg->msg_state = HTTP_MSG_CHUNK_SIZE;
- else {
+ else
msg->msg_state = HTTP_MSG_DATA;
- }
}
while (1) {
@@ -5404,7 +5400,7 @@
/* nothing left to forward */
if (msg->flags & HTTP_MSGF_TE_CHNK)
- msg->msg_state = HTTP_MSG_DATA_CRLF;
+ msg->msg_state = HTTP_MSG_CHUNK_CRLF;
else
msg->msg_state = HTTP_MSG_DONE;
}
@@ -5415,7 +5411,7 @@
*/
int ret = http_parse_chunk_size(msg);
- if (!ret)
+ if (ret == 0)
goto missing_data;
else if (ret < 0) {
if (msg->err_pos >= 0)
@@ -5424,17 +5420,15 @@
}
/* otherwise we're in HTTP_MSG_DATA or HTTP_MSG_TRAILERS state */
}
- else if (msg->msg_state == HTTP_MSG_DATA_CRLF) {
+ else if (msg->msg_state == HTTP_MSG_CHUNK_CRLF) {
/* we want the CRLF after the data */
- int ret;
+ int ret = http_skip_chunk_crlf(msg);
- ret = http_skip_chunk_crlf(msg);
-
- if (!ret)
+ if (ret == 0)
goto missing_data;
else if (ret < 0) {
if (msg->err_pos >= 0)
- http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_DATA_CRLF, s->fe);
+ http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_CHUNK_CRLF, s->fe);
goto return_bad_res;
}
/* we're in MSG_CHUNK_SIZE now */