mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-20 20:50:44 +00:00
MINOR: proto-http: Add sample fetch wich returns all HTTP headers
The sample fetch returns all headers including the last jump line. The last jump line is used to determine if the block of headers is truncated or not.
This commit is contained in:
parent
5617dce27d
commit
d7d8881543
@ -14167,6 +14167,12 @@ payload_lv(<offset1>,<length>[,<offset2>]) : binary (deprecated)
|
||||
(eg: "stick on", "stick match"), and for "res.payload_lv" when used in the
|
||||
context of a response such as in "stick store response".
|
||||
|
||||
req.hdrs : string
|
||||
Returns the current request headers as string including the last empty line
|
||||
separating headers from the request body. The last empty line can be used to
|
||||
detect a truncated header block. This sample fetch is useful for some SPOE
|
||||
headers analyzers and for advanced logging.
|
||||
|
||||
req.hdrs_bin : binary
|
||||
Returns the current request headers contained in preparsed binary form. This
|
||||
is useful for offloading some processing with SPOE. Each string is described
|
||||
|
@ -10437,6 +10437,31 @@ smp_fetch_uniqueid(const struct arg *args, struct sample *smp, const char *kw, v
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Returns a string block containing all headers including the
|
||||
* empty line wich separes headers from the body. This is useful
|
||||
* form some headers analysis.
|
||||
*/
|
||||
static int
|
||||
smp_fetch_hdrs(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
struct http_msg *msg;
|
||||
struct hdr_idx *idx;
|
||||
struct http_txn *txn;
|
||||
|
||||
CHECK_HTTP_MESSAGE_FIRST();
|
||||
|
||||
txn = smp->strm->txn;
|
||||
idx = &txn->hdr_idx;
|
||||
msg = &txn->req;
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.u.str.str = msg->chn->buf->p + hdr_idx_first_pos(idx);
|
||||
smp->data.u.str.len = msg->eoh - hdr_idx_first_pos(idx) + 1 +
|
||||
(msg->chn->buf->p[msg->eoh] == '\r');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Returns the header request in a length/value encoded format.
|
||||
* This is useful for exchanges with the SPOE.
|
||||
*
|
||||
@ -13457,6 +13482,7 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
|
||||
{ "req.body_size", smp_fetch_body_size, 0, NULL, SMP_T_SINT, SMP_USE_HRQHV },
|
||||
{ "req.body_param", smp_fetch_body_param, ARG1(0,STR), NULL, SMP_T_BIN, SMP_USE_HRQHV },
|
||||
|
||||
{ "req.hdrs", smp_fetch_hdrs, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV },
|
||||
{ "req.hdrs_bin", smp_fetch_hdrs_bin, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV },
|
||||
|
||||
/* HTTP version on the response path */
|
||||
|
Loading…
Reference in New Issue
Block a user