Skip to content

Commit 6374943

Browse files
nokute78edsiper
authored andcommitted
http_client: add flb_http_get_header
Signed-off-by: Takahiro Yamashita <[email protected]>
1 parent c62b165 commit 6374943

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

include/fluent-bit/flb_http_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ struct flb_http_client *flb_http_client(struct flb_upstream_conn *u_conn,
148148
int flb_http_add_header(struct flb_http_client *c,
149149
const char *key, size_t key_len,
150150
const char *val, size_t val_len);
151+
flb_sds_t flb_http_get_header(struct flb_http_client *c,
152+
const char *key, size_t key_len);
151153
int flb_http_basic_auth(struct flb_http_client *c,
152154
const char *user, const char *passwd);
153155
int flb_http_proxy_auth(struct flb_http_client *c,

src/flb_http_client.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,30 @@ int flb_http_add_header(struct flb_http_client *c,
915915
return 0;
916916
}
917917

918+
/*
919+
* flb_http_get_header looks up a first value of request header.
920+
* The return value should be destroyed after using.
921+
* The return value is NULL, if the value is not found.
922+
*/
923+
flb_sds_t flb_http_get_header(struct flb_http_client *c,
924+
const char *key, size_t key_len)
925+
{
926+
flb_sds_t ret_str;
927+
struct flb_kv *kv;
928+
struct mk_list *head = NULL;
929+
struct mk_list *tmp = NULL;
930+
931+
mk_list_foreach_safe(head, tmp, &c->headers) {
932+
kv = mk_list_entry(head, struct flb_kv, _head);
933+
if (flb_sds_casecmp(kv->key, key, key_len) == 0) {
934+
ret_str = flb_sds_create(kv->val);
935+
return ret_str;
936+
}
937+
}
938+
939+
return NULL;
940+
}
941+
918942
static int http_header_push(struct flb_http_client *c, struct flb_kv *header)
919943
{
920944
char *tmp;

0 commit comments

Comments
 (0)