changeset 773:c1dd6bdfffe0

merge with main
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Fri, 16 Jan 2009 14:55:37 +0100
parents c1104104babf (current diff) 96a14e974cfb (diff)
children c40b6d8a1e79
files ChangeLog dillorc src/prefs.c src/prefs.h
diffstat 5 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jan 16 10:37:30 2009 -0300
+++ b/ChangeLog	Fri Jan 16 14:55:37 2009 +0100
@@ -24,6 +24,7 @@
  - 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.
--- a/dillorc	Fri Jan 16 10:37:30 2009 -0300
+++ b/dillorc	Fri Jan 16 14:55:37 2009 +0100
@@ -99,6 +99,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,
--- a/src/IO/http.c	Fri Jan 16 10:37:30 2009 -0300
+++ b/src/IO/http.c	Fri Jan 16 14:55:37 2009 +0100
@@ -68,14 +68,19 @@
 
 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 @@
          "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 @@
          "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 @@
          "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 @@
          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);
--- a/src/prefs.c	Fri Jan 16 10:37:30 2009 -0300
+++ b/src/prefs.c	Fri Jan 16 14:55:37 2009 +0100
@@ -70,6 +70,7 @@
    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,
@@ -133,6 +134,7 @@
    { "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 },
@@ -205,6 +207,10 @@
       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);
@@ -420,6 +426,7 @@
    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");
@@ -485,6 +492,7 @@
  */
 void a_Prefs_freeall(void)
 {
+   dFree(prefs.http_language);
    dFree(prefs.http_proxyuser);
    dFree(prefs.http_referer);
    dFree(prefs.no_proxy);
--- a/src/prefs.h	Fri Jan 16 10:37:30 2009 -0300
+++ b/src/prefs.h	Fri Jan 16 14:55:37 2009 +0100
@@ -22,6 +22,7 @@
    int height;
    int xpos;
    int ypos;
+   char *http_language;
    DilloUrl *http_proxy;
    char *http_proxyuser;
    char *http_referer;