mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MEDIUM: http: small helpers to compute how far to rewind to find BODY and DATA
http_body_rewind() returns the number of bytes to rewind before buf->p to find the message's body. It relies on http_hdr_rewind() to find the beginning and adds msg->eoh + msg->eol which are always safe. http_data_rewind() does the same to get the beginning of the data, which differs from above when a chunk is present. It uses the function above and adds msg->sol. The purpose is to centralize further ->sov changes aiming at avoiding to rely on buf->o.
This commit is contained in:
parent
da6eed621f
commit
0d09050aa5
@ -149,6 +149,27 @@ static inline int http_uri_rewind(const struct http_msg *msg)
|
||||
return http_hdr_rewind(msg) - msg->sl.rq.u;
|
||||
}
|
||||
|
||||
/* Return the amount of bytes that need to be rewound before buf->p to access
|
||||
* the current message's BODY. The purpose is to be able to easily fetch
|
||||
* the message's beginning before headers are forwarded, as well as after.
|
||||
*/
|
||||
static inline int http_body_rewind(const struct http_msg *msg)
|
||||
{
|
||||
return http_hdr_rewind(msg) - msg->eoh - msg->eol;
|
||||
}
|
||||
|
||||
/* Return the amount of bytes that need to be rewound before buf->p to access
|
||||
* the current message's DATA. The difference with the function above is that
|
||||
* if a chunk is present and has already been parsed, its size is skipped so
|
||||
* that the byte pointed to is the first byte of actual data. The function is
|
||||
* safe for use in state HTTP_MSG_DATA regardless of whether the headers were
|
||||
* already forwarded or not.
|
||||
*/
|
||||
static inline int http_data_rewind(const struct http_msg *msg)
|
||||
{
|
||||
return http_body_rewind(msg) - msg->sol;
|
||||
}
|
||||
|
||||
/* Return the maximum amount of bytes that may be read after the beginning of
|
||||
* the message body, according to the advertised length. The function is safe
|
||||
* for use between HTTP_MSG_BODY and HTTP_MSG_DATA regardless of whether the
|
||||
|
@ -299,7 +299,7 @@ struct server *get_server_ph_post(struct session *s)
|
||||
struct proxy *px = s->be;
|
||||
unsigned int plen = px->url_param_len;
|
||||
unsigned long len = http_body_bytes(msg);
|
||||
const char *params = b_ptr(req->buf, (int)(msg->sov + msg->sol - http_hdr_rewind(msg)));
|
||||
const char *params = b_ptr(req->buf, -http_data_rewind(msg));
|
||||
const char *p = params;
|
||||
const char *start, *end;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user