From 9c0c3d5ced559cb723247a54475fa59b403560b0 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Fri, 8 Jan 2010 22:05:17 +0530 Subject: [BB#17] Add custom HTTP request headers to outgoing HTTP requests --- src/reqs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/reqs.c') diff --git a/src/reqs.c b/src/reqs.c index 2f6b67e..a2df786 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -1327,6 +1327,7 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request) */ void handle_connection (int fd) { + ssize_t i; struct conn_s *connptr; struct request_s *request = NULL; hashmap_t hashofheaders = NULL; @@ -1407,6 +1408,19 @@ void handle_connection (int fd) return; } + /* + * Add any user-specified headers (AddHeader directive) to the + * outgoing HTTP request. + */ + for (i = 0; i < vector_length (config.add_headers); i++) { + http_header_t *header = (http_header_t *) + vector_getentry (config.add_headers, i, NULL); + + hashmap_insert (hashofheaders, + header->name, + header->value, strlen (header->value) + 1); + } + request = process_request (connptr, hashofheaders); if (!request) { if (!connptr->error_variables && !connptr->show_stats) { -- cgit v1.2.3