From b306c7c9d5e5577b6289b003a1d72583dae16a8a Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 13 Feb 2015 20:13:50 +0100 Subject: [PATCH] http: allow to specify different paths --- src/http.c | 11 ++++++----- src/http.h | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/http.c b/src/http.c index 382addee..f67f0094 100644 --- a/src/http.c +++ b/src/http.c @@ -39,7 +39,7 @@ void *http_server; -static LIST_HEAD(, http_path) http_paths; +static http_path_list_t http_paths; static struct strtab HTTP_cmdtab[] = { { "GET", HTTP_CMD_GET }, @@ -113,7 +113,7 @@ http_resolve(http_connection_t *hc, char **remainp, char **argsp) while (1) { - LIST_FOREACH(hp, &http_paths, hp_link) { + LIST_FOREACH(hp, hc->hc_paths, hp_link) { if(!strncmp(path, hp->hp_path, hp->hp_len)) { if(path[hp->hp_len] == 0 || path[hp->hp_len] == '/' || @@ -1000,9 +1000,10 @@ http_serve(int fd, void **opaque, struct sockaddr_storage *peer, memset(&hc, 0, sizeof(http_connection_t)); *opaque = &hc; - hc.hc_fd = fd; - hc.hc_peer = peer; - hc.hc_self = self; + hc.hc_fd = fd; + hc.hc_peer = peer; + hc.hc_self = self; + hc.hc_paths = &http_paths; http_serve_requests(&hc); diff --git a/src/http.h b/src/http.h index cedd136b..468df567 100644 --- a/src/http.h +++ b/src/http.h @@ -25,6 +25,9 @@ #include "access.h" struct channel; +struct http_path; + +typedef LIST_HEAD(, http_path) http_path_list_t; typedef TAILQ_HEAD(http_arg_list, http_arg) http_arg_list_t; @@ -115,6 +118,8 @@ typedef struct http_connection { struct sockaddr_storage *hc_self; char *hc_representative; + http_path_list_t *hc_paths; + char *hc_url; char *hc_url_orig; int hc_keep_alive;