Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http: allow to specify different paths
  • Loading branch information
perexg committed Mar 11, 2015
1 parent 3c95a84 commit b306c7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/http.c
Expand Up @@ -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 },
Expand Down Expand Up @@ -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] == '/' ||
Expand Down Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions src/http.h
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b306c7c

Please sign in to comment.