From adb3d5c87fae7196dbae6c35828434cdcd6227a4 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 15 Jan 2009 18:33:04 -0300 Subject: Added the "http_language" dillorc option for setting HTTP's Accept-Language. --- ChangeLog | 1 + dillorc | 9 +++++++++ src/IO/http.c | 15 +++++++++++---- src/prefs.c | 8 ++++++++ src/prefs.h | 1 + 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a7f4e94..f43fb942 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ dillo-2.1 - Switched file dpi error messages to HTML. - Added a popup menu to form's submit button. - Added a right-click menu to the form submit button (allows to show hiddens). + - Added the "http_language" dillorc option for setting HTTP's Accept-Language. Patches: place (AKA corvid) +- Switched SSL-enabled to configure.in (./configure --enable-ssl). - Standardised the installation of dpid/dpidrc with auto* tools. diff --git a/dillorc b/dillorc index 0b22d74f..8b0ae75f 100644 --- a/dillorc +++ b/dillorc @@ -97,6 +97,15 @@ # search_url="http://www.alltheweb.com/search?cat=web&query=%s" #search_url="http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" +# If set, dillo will ask web servers to send pages in this language. +# This setting does NOT change dillo's user interface. +# Format explained: www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 +# Language-REGION values: www.iana.org/assignments/language-subtag-registry +# (by default, no Accept-Language header is sent) +# http_language="de" +# http_language="pt-BR" +# http_language="vi,de-CH,de;q=0.5,th;q=0.3" + # Set the proxy information for http. # WARNING: - HTTPS does not currently use the proxy settings. # - FTP and downloads plugins use wget. To use a proxy with them, diff --git a/src/IO/http.c b/src/IO/http.c index 328a8601..738937db 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -68,14 +68,19 @@ static Klist_t *ValidSocks = NULL; /* Active sockets list. It holds pointers to static DilloUrl *HTTP_Proxy = NULL; static char *HTTP_Proxy_Auth_base64 = NULL; +static char *HTTP_Language_hdr = NULL; /* - * Initialize proxy vars. + * Initialize proxy vars and Accept-Language header */ int a_Http_init(void) { char *env_proxy = getenv("http_proxy"); + HTTP_Language_hdr = prefs.http_language ? + dStrconcat("Accept-Language: ", prefs.http_language, "\r\n", NULL) : + dStrdup(""); + if (env_proxy && strlen(env_proxy)) HTTP_Proxy = a_Url_new(env_proxy, NULL); if (!HTTP_Proxy && prefs.http_proxy) @@ -231,6 +236,7 @@ Dstr *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) "Connection: close\r\n" "Accept-Charset: utf-8,*;q=0.8\r\n" "Accept-Encoding: gzip\r\n" + "%s" /* language */ "%s" /* auth */ "Host: %s\r\n" "%s" @@ -240,8 +246,8 @@ Dstr *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) "Content-Type: %s\r\n" "%s" /* cookies */ "\r\n", - full_path->str, auth ? auth : "", URL_AUTHORITY(url), - proxy_auth->str, referer, VERSION, + full_path->str, HTTP_Language_hdr, auth ? auth : "", + URL_AUTHORITY(url), proxy_auth->str, referer, VERSION, URL_DATA(url)->len, content_type->str, cookies); dStr_append_l(query, URL_DATA(url)->str, URL_DATA(url)->len); @@ -254,6 +260,7 @@ Dstr *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) "Connection: close\r\n" "Accept-Charset: utf-8,*;q=0.8\r\n" "Accept-Encoding: gzip\r\n" + "%s" /* language */ "%s" /* auth */ "Host: %s\r\n" "%s" @@ -264,7 +271,7 @@ Dstr *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) full_path->str, (URL_FLAGS(url) & URL_E2EQuery) ? "Cache-Control: no-cache\r\nPragma: no-cache\r\n" : "", - auth ? auth : "", URL_AUTHORITY(url), + HTTP_Language_hdr, auth ? auth : "", URL_AUTHORITY(url), proxy_auth->str, referer, VERSION, cookies); } dFree(referer); diff --git a/src/prefs.c b/src/prefs.c index d7042924..f044d247 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -70,6 +70,7 @@ typedef enum { DRC_TOKEN_GENERATE_SUBMIT, DRC_TOKEN_GEOMETRY, DRC_TOKEN_HOME, + DRC_TOKEN_HTTP_LANGUAGE, DRC_TOKEN_LIMIT_TEXT_WIDTH, DRC_TOKEN_LINK_COLOR, DRC_TOKEN_LOAD_IMAGES, @@ -132,6 +133,7 @@ static const SymNode_t symbols[] = { { "generate_submit", DRC_TOKEN_GENERATE_SUBMIT }, { "geometry", DRC_TOKEN_GEOMETRY }, { "home", DRC_TOKEN_HOME }, + { "http_language", DRC_TOKEN_HTTP_LANGUAGE }, { "http_proxy", DRC_TOKEN_PROXY }, { "http_proxyuser", DRC_TOKEN_PROXYUSER }, { "http_referer", DRC_TOKEN_REFERER }, @@ -203,6 +205,10 @@ static int Prefs_parse_pair(char *name, char *value) a_Misc_parse_geometry(value, &prefs.xpos, &prefs.ypos, &prefs.width, &prefs.height); break; + case DRC_TOKEN_HTTP_LANGUAGE: + dFree(prefs.http_language); + prefs.http_language = dStrdup(value); + break; case DRC_TOKEN_PROXY: a_Url_free(prefs.http_proxy); prefs.http_proxy = a_Url_new(value, NULL); @@ -415,6 +421,7 @@ void a_Prefs_init(void) prefs.height = D_GEOMETRY_DEFAULT_HEIGHT; prefs.xpos = D_GEOMETRY_DEFAULT_XPOS; prefs.ypos = D_GEOMETRY_DEFAULT_YPOS; + prefs.http_language = NULL; prefs.http_proxy = NULL; prefs.http_proxyuser = NULL; prefs.http_referer = dStrdup("host"); @@ -479,6 +486,7 @@ void a_Prefs_init(void) */ void a_Prefs_freeall(void) { + dFree(prefs.http_language); dFree(prefs.http_proxyuser); dFree(prefs.http_referer); dFree(prefs.no_proxy); diff --git a/src/prefs.h b/src/prefs.h index a12e5a37..6fee1620 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -22,6 +22,7 @@ struct _DilloPrefs { int height; int xpos; int ypos; + char *http_language; DilloUrl *http_proxy; char *http_proxyuser; char *http_referer; -- cgit v1.2.3