diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-09-01 19:30:49 +0400 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-09-01 19:30:49 +0400 |
commit | b424930e4ea971ff8675c30d5dc4445c173b2b1a (patch) | |
tree | 244487bdb81314807c70d699b90d6116060cb14e /networking/httpd.c | |
parent | 2bdc99f600e0f6ee4b83dac3c80287f4e2d1bf96 (diff) |
- pass "Accept:" and "Accept-Language:" header to CGI scripts (Alina Friedrichsen)
Alina writes:
With this patch the BusyBox httpd pass the "Accept:" and
"Accept-Language:" header by the environment variables to the
CGI-Script, so this can make Content Negotiation to deliver the page in
the language, which was selected by the user in the browser settings,
and/or serve the XHTML page with the right MIME-Type
application/xhtml+xml to user agents which support it und text/html
which don't.
(Needed e.g. for OpenWrt LuCI.)
Signed-off-by: Alina Friedrichsen <x-alina at gmx dot net>
Diffstat (limited to 'networking/httpd.c')
-rw-r--r-- | networking/httpd.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 82891f121..db8eb1e9c 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -254,6 +254,8 @@ struct globals { USE_FEATURE_HTTPD_BASIC_AUTH(char *remoteuser;) USE_FEATURE_HTTPD_CGI(char *referer;) USE_FEATURE_HTTPD_CGI(char *user_agent;) + USE_FEATURE_HTTPD_CGI(char *http_accept;) + USE_FEATURE_HTTPD_CGI(char *http_accept_language;) off_t file_size; /* -1 - unknown */ #if ENABLE_FEATURE_HTTPD_RANGES @@ -299,6 +301,8 @@ struct globals { #define remoteuser (G.remoteuser ) #define referer (G.referer ) #define user_agent (G.user_agent ) +#define http_accept (G.http_accept ) +#define http_accept_language (G.http_accept_language) #define file_size (G.file_size ) #if ENABLE_FEATURE_HTTPD_RANGES #define range_start (G.range_start ) @@ -1384,6 +1388,10 @@ static void send_cgi_and_exit( } } setenv1("HTTP_USER_AGENT", user_agent); + if (http_accept) + setenv1("HTTP_ACCEPT", http_accept); + if (http_accept_language) + setenv1("HTTP_ACCEPT_LANGUAGE", http_accept_language); if (post_len) putenv(xasprintf("CONTENT_LENGTH=%d", post_len)); if (cookie) @@ -2005,6 +2013,10 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) referer = xstrdup(skip_whitespace(iobuf + sizeof("Referer:")-1)); } else if (STRNCASECMP(iobuf, "User-Agent:") == 0) { user_agent = xstrdup(skip_whitespace(iobuf + sizeof("User-Agent:")-1)); + } else if (STRNCASECMP(iobuf, "Accept:") == 0) { + http_accept = xstrdup(skip_whitespace(iobuf + sizeof("Accept:")-1)); + } else if (STRNCASECMP(iobuf, "Accept-Language:") == 0) { + http_accept_language = xstrdup(skip_whitespace(iobuf + sizeof("Accept-Language:")-1)); } #endif #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |