mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-09 19:28:02 +00:00
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.
This commit is contained in:
parent
fa4a03ca08
commit
12e48b36dd
@ -311,7 +311,7 @@ struct http_msg {
|
|||||||
unsigned int sov; /* current header: start of value */
|
unsigned int sov; /* current header: start of value */
|
||||||
unsigned int eoh; /* End Of Headers, relative to buffer */
|
unsigned int eoh; /* End Of Headers, relative to buffer */
|
||||||
char *sol; /* start of line, also start of message when fully parsed */
|
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 */
|
unsigned int som; /* Start Of Message, relative to buffer's origin */
|
||||||
int err_pos; /* err handling: -2=block, -1=pass, 0+=detected */
|
int err_pos; /* err handling: -2=block, -1=pass, 0+=detected */
|
||||||
union { /* useful start line pointers, relative to ->sol */
|
union { /* useful start line pointers, relative to ->sol */
|
||||||
|
@ -1495,7 +1495,7 @@ void http_msg_analyzer(struct buffer *buf, struct http_msg *msg, struct hdr_idx
|
|||||||
goto http_msg_hdr_l1_sp;
|
goto http_msg_hdr_l1_sp;
|
||||||
}
|
}
|
||||||
/* we had a header consisting only in spaces ! */
|
/* we had a header consisting only in spaces ! */
|
||||||
msg->eol = buf->p + msg->sov;
|
msg->eol = msg->sov;
|
||||||
goto http_msg_complete_header;
|
goto http_msg_complete_header;
|
||||||
|
|
||||||
case HTTP_MSG_HDR_VAL:
|
case HTTP_MSG_HDR_VAL:
|
||||||
@ -1506,7 +1506,7 @@ void http_msg_analyzer(struct buffer *buf, struct http_msg *msg, struct hdr_idx
|
|||||||
if (likely(!HTTP_IS_CRLF(*ptr)))
|
if (likely(!HTTP_IS_CRLF(*ptr)))
|
||||||
EAT_AND_JUMP_OR_RETURN(http_msg_hdr_val, HTTP_MSG_HDR_VAL);
|
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
|
/* 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
|
* real header end in case it ends with lots of LWS, but is this
|
||||||
* really needed ?
|
* really needed ?
|
||||||
@ -1524,8 +1524,8 @@ void http_msg_analyzer(struct buffer *buf, struct http_msg *msg, struct hdr_idx
|
|||||||
http_msg_hdr_l2_lws:
|
http_msg_hdr_l2_lws:
|
||||||
if (unlikely(HTTP_IS_SPHT(*ptr))) {
|
if (unlikely(HTTP_IS_SPHT(*ptr))) {
|
||||||
/* LWS: replace HT,CR,LF with spaces */
|
/* LWS: replace HT,CR,LF with spaces */
|
||||||
for (; msg->eol < ptr; msg->eol++)
|
for (; buf->p + msg->eol < ptr; msg->eol++)
|
||||||
*msg->eol = ' ';
|
buf->p[msg->eol] = ' ';
|
||||||
goto http_msg_hdr_val;
|
goto http_msg_hdr_val;
|
||||||
}
|
}
|
||||||
http_msg_complete_header:
|
http_msg_complete_header:
|
||||||
@ -1536,13 +1536,7 @@ void http_msg_analyzer(struct buffer *buf, struct http_msg *msg, struct hdr_idx
|
|||||||
* first CR or LF so we know how the line ends. We insert last
|
* first CR or LF so we know how the line ends. We insert last
|
||||||
* header into the index.
|
* header into the index.
|
||||||
*/
|
*/
|
||||||
/*
|
if (unlikely(hdr_idx_add((msg->eol + buf->p) - msg->sol, buf->p[msg->eol] == '\r',
|
||||||
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',
|
|
||||||
idx, idx->tail) < 0))
|
idx, idx->tail) < 0))
|
||||||
goto http_msg_invalid;
|
goto http_msg_invalid;
|
||||||
|
|
||||||
@ -1990,7 +1984,6 @@ void http_buffer_heavy_realign(struct buffer *buf, struct http_msg *msg)
|
|||||||
/* adjust all known pointers */
|
/* adjust all known pointers */
|
||||||
buf->p = buf->data;
|
buf->p = buf->data;
|
||||||
msg->sol += off; if (msg->sol >= end) msg->sol -= buf->size;
|
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) {
|
if (msg->err_pos >= 0) {
|
||||||
msg->err_pos += off;
|
msg->err_pos += off;
|
||||||
@ -7347,12 +7340,12 @@ void http_init_txn(struct session *s)
|
|||||||
txn->cookie_last_date = 0;
|
txn->cookie_last_date = 0;
|
||||||
|
|
||||||
txn->req.flags = 0;
|
txn->req.flags = 0;
|
||||||
txn->req.sol = txn->req.eol = NULL;
|
txn->req.sol = NULL;
|
||||||
txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
|
txn->req.eol = txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
|
||||||
txn->req.next = 0;
|
txn->req.next = 0;
|
||||||
txn->rsp.flags = 0;
|
txn->rsp.flags = 0;
|
||||||
txn->rsp.sol = txn->rsp.eol = NULL;
|
txn->rsp.sol = NULL;
|
||||||
txn->rsp.som = txn->rsp.eoh = 0; /* relative to the buffer */
|
txn->rsp.eol = txn->rsp.som = txn->rsp.eoh = 0; /* relative to the buffer */
|
||||||
txn->rsp.next = 0;
|
txn->rsp.next = 0;
|
||||||
txn->req.chunk_len = 0LL;
|
txn->req.chunk_len = 0LL;
|
||||||
txn->req.body_len = 0LL;
|
txn->req.body_len = 0LL;
|
||||||
|
Loading…
Reference in New Issue
Block a user