Remi,
please find a suggested cleanup for your JWT patch series. I think that
using the ist functions results in easier to understand code, because you
don't need to manually calculate lengths and offsets.
Apply with `git am --scissors` to automatically cut the commit message.
-- >8 --
Using the ist helper functions is arguably cleaner than using C's regular
string functions on an ist.
---
src/http_fetch.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/http_fetch.c b/src/http_fetch.c
index 7b4e41d85..61545d66f 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -1369,10 +1369,10 @@ static int smp_fetch_http_auth_bearer(const struct arg
*args, struct sample *smp
ctx.blk = NULL;
if (http_find_header(htx, hdr_name, &ctx, 0)) {
- char *space = NULL;
- space = memchr(ctx.value.ptr, ' ', ctx.value.len);
- if (space && strncasecmp("Bearer", ctx.value.ptr,
ctx.value.len) == 0) {
- chunk_initlen(&bearer_val, space+1, 0,
ctx.value.len - (space - ctx.value.ptr) - 1);
+ struct ist type = istsplit(&ctx.value, ' ');
+
+ if (isteqi(type, ist("Bearer")) && istend(type) !=
istend(ctx.value)) {
+ chunk_initlen(&bearer_val, istptr(ctx.value),
0, istlen(ctx.value));
}
}
}
--
2.33.0