X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-hreq.c;h=f7f3bb15a17e820457f57e91a40604bff33b4cd1;hb=ca208671cc79bbc05c574df788035878e5d39382;hp=19efd4b2b3cea7054dc3a6e21bddeedeff7f2754;hpb=3a10185ae380956bd356c73f34138f97255bf7e6;p=src%2Fapp-framework-binder.git diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 19efd4b2..f7f3bb15 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -23,11 +23,12 @@ #include "../include/local-def.h" #include "afb-method.h" +#include "afb-req-itf.h" #include "afb-hreq.h" - static char empty_string[1] = ""; + /* a valid subpath is a relative path not looking deeper than root using .. */ static int validsubpath(const char *subpath) { @@ -74,7 +75,7 @@ int afb_hreq_unprefix(struct afb_hreq *hreq, const char *prefix, size_t length) { /* check the prefix ? */ if (length > hreq->lentail || (hreq->tail[length] && hreq->tail[length] != '/') - || memcmp(prefix, hreq->tail, length)) + || strncasecmp(prefix, hreq->tail, length)) return 0; /* removes successives / */ @@ -229,3 +230,23 @@ int afb_hreq_redirect_to(struct afb_hreq *hreq, const char *url) return 1; } +const char *afb_hreq_get_cookie(struct afb_hreq *hreq, const char *name) +{ + return MHD_lookup_connection_value(hreq->connection, MHD_COOKIE_KIND, name); +} + +const char *afb_hreq_get_argument(struct afb_hreq *hreq, const char *name) +{ + return MHD_lookup_connection_value(hreq->connection, MHD_GET_ARGUMENT_KIND, name); +} + +const char *afb_hreq_get_header(struct afb_hreq *hreq, const char *name) +{ + return MHD_lookup_connection_value(hreq->connection, MHD_HEADER_KIND, name); +} + +struct afb_req_itf afb_hreq_itf = { + .get_cookie = (void*)afb_hreq_get_cookie, + .get_argument = (void*)afb_hreq_get_argument +}; +