MAJOR: http: turn http_msg->eol to a buffer-relative offset
It was an absolute pointer to the buffer's data, now it's a pointer relative
to the buffer's origin.
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index ecc26e6..5df00bd 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -311,7 +311,7 @@
unsigned int sov; /* current header: start of value */
unsigned int eoh; /* End Of Headers, relative to buffer */
char *sol; /* start of line, also start of message when fully parsed */
- char *eol; /* end of line */
+ unsigned int eol; /* end of line */
unsigned int som; /* Start Of Message, relative to buffer's origin */
int err_pos; /* err handling: -2=block, -1=pass, 0+=detected */
union { /* useful start line pointers, relative to ->sol */
diff --git a/src/proto_http.c b/src/proto_http.c
index ff337e5..0f5a509 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -1495,7 +1495,7 @@
goto http_msg_hdr_l1_sp;
}
/* we had a header consisting only in spaces ! */
- msg->eol = buf->p + msg->sov;
+ msg->eol = msg->sov;
goto http_msg_complete_header;
case HTTP_MSG_HDR_VAL:
@@ -1506,7 +1506,7 @@
if (likely(!HTTP_IS_CRLF(*ptr)))
EAT_AND_JUMP_OR_RETURN(http_msg_hdr_val, HTTP_MSG_HDR_VAL);
- msg->eol = ptr;
+ msg->eol = ptr - buf->p;
/* Note: we could also copy eol into ->eoh so that we have the
* real header end in case it ends with lots of LWS, but is this
* really needed ?
@@ -1524,8 +1524,8 @@
http_msg_hdr_l2_lws:
if (unlikely(HTTP_IS_SPHT(*ptr))) {
/* LWS: replace HT,CR,LF with spaces */
- for (; msg->eol < ptr; msg->eol++)
- *msg->eol = ' ';
+ for (; buf->p + msg->eol < ptr; msg->eol++)
+ buf->p[msg->eol] = ' ';
goto http_msg_hdr_val;
}
http_msg_complete_header:
@@ -1536,13 +1536,7 @@
* first CR or LF so we know how the line ends. We insert last
* header into the index.
*/
- /*
- fprintf(stderr,"registering %-2d bytes : ", msg->eol - msg->sol);
- write(2, msg->sol, msg->eol-msg->sol);
- fprintf(stderr,"\n");
- */
-
- if (unlikely(hdr_idx_add(msg->eol - msg->sol, *msg->eol == '\r',
+ if (unlikely(hdr_idx_add((msg->eol + buf->p) - msg->sol, buf->p[msg->eol] == '\r',
idx, idx->tail) < 0))
goto http_msg_invalid;
@@ -1990,7 +1984,6 @@
/* adjust all known pointers */
buf->p = buf->data;
msg->sol += off; if (msg->sol >= end) msg->sol -= buf->size;
- msg->eol += off; if (msg->eol >= end) msg->eol -= buf->size;
if (msg->err_pos >= 0) {
msg->err_pos += off;
@@ -7347,12 +7340,12 @@
txn->cookie_last_date = 0;
txn->req.flags = 0;
- txn->req.sol = txn->req.eol = NULL;
- txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
+ txn->req.sol = NULL;
+ txn->req.eol = txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
txn->req.next = 0;
txn->rsp.flags = 0;
- txn->rsp.sol = txn->rsp.eol = NULL;
- txn->rsp.som = txn->rsp.eoh = 0; /* relative to the buffer */
+ txn->rsp.sol = NULL;
+ txn->rsp.eol = txn->rsp.som = txn->rsp.eoh = 0; /* relative to the buffer */
txn->rsp.next = 0;
txn->req.chunk_len = 0LL;
txn->req.body_len = 0LL;