You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2 KiB

  1. From 2943734024525d4b9aeec13cca2c1d230c358ee5 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Wed, 1 Apr 2015 19:16:09 +0200
  4. Subject: [PATCH 9/9] BUG/MEDIUM: http: hdr_cnt would not count any header when
  5. called without name
  6. It's documented that these sample fetch functions should count all headers
  7. and/or all values when called with no name but in practice it's not what is
  8. being done as a missing name causes an immediate return and an absence of
  9. result.
  10. This bug is present in 1.5 as well and must be backported.
  11. (cherry picked from commit 601a4d1741100d7a861b6d9b66561335c9911277)
  12. ---
  13. src/proto_http.c | 20 ++++++++++++++------
  14. 1 file changed, 14 insertions(+), 6 deletions(-)
  15. diff --git a/src/proto_http.c b/src/proto_http.c
  16. index c49c4f4..ccd52ad 100644
  17. --- a/src/proto_http.c
  18. +++ b/src/proto_http.c
  19. @@ -10014,15 +10014,19 @@ smp_fetch_fhdr_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int
  20. struct hdr_ctx ctx;
  21. const struct http_msg *msg = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ) ? &txn->req : &txn->rsp;
  22. int cnt;
  23. + const char *name = NULL;
  24. + int len = 0;
  25. - if (!args || args->type != ARGT_STR)
  26. - return 0;
  27. + if (args && args->type == ARGT_STR) {
  28. + name = args->data.str.str;
  29. + len = args->data.str.len;
  30. + }
  31. CHECK_HTTP_MESSAGE_FIRST();
  32. ctx.idx = 0;
  33. cnt = 0;
  34. - while (http_find_full_header2(args->data.str.str, args->data.str.len, msg->chn->buf->p, idx, &ctx))
  35. + while (http_find_full_header2(name, len, msg->chn->buf->p, idx, &ctx))
  36. cnt++;
  37. smp->type = SMP_T_UINT;
  38. @@ -10101,15 +10105,19 @@ smp_fetch_hdr_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int o
  39. struct hdr_ctx ctx;
  40. const struct http_msg *msg = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ) ? &txn->req : &txn->rsp;
  41. int cnt;
  42. + const char *name = NULL;
  43. + int len = 0;
  44. - if (!args || args->type != ARGT_STR)
  45. - return 0;
  46. + if (args && args->type == ARGT_STR) {
  47. + name = args->data.str.str;
  48. + len = args->data.str.len;
  49. + }
  50. CHECK_HTTP_MESSAGE_FIRST();
  51. ctx.idx = 0;
  52. cnt = 0;
  53. - while (http_find_header2(args->data.str.str, args->data.str.len, msg->chn->buf->p, idx, &ctx))
  54. + while (http_find_header2(name, len, msg->chn->buf->p, idx, &ctx))
  55. cnt++;
  56. smp->type = SMP_T_UINT;
  57. --
  58. 2.0.5