Subject: bug#33002: 26.1; EWW sends unspecific "Accept: */*" header

From: Federico Tedin <[email-masked]>
Date: Sun, 4 Nov 2018 00:15:38 -0300

I've created a small patch which introduces a new variable, its value is
used as the value for the 'Accept' HTTP header in requests created by EWW.
As the default value I chose to use the same Lynx uses.
From b2fe312aa5232fa3cfc259feb3cf313ae85faa9b Mon Sep 17 00:00:00 2001
From: Federico Tedin <[email-masked]>
Date: Sun, 4 Nov 2018 00:07:52 -0300
Subject: [PATCH 1/1] Adds variable 'eww-accept-content-types'

* lisp/net/eww.el (eww-accept-content-types): New variable.
  (eww): Use it (Bug#33002).
  (eww-reload): Use it.
* etc/NEWS: Mention 'eww-accept-content-types'.
---
 etc/NEWS        |  4 ++++
 lisp/net/eww.el | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 1020a2a0ea..f5203c6b11 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -511,6 +511,10 @@ and its value has been changed to Duck Duck Go.
 'shr-selected-link' face to give the user feedback that the command
 has been executed.
 
+*** New customizable variable 'eww-accept-content-types'
+This new variable controls the value of the 'Accept' header sent in
+HTTP requests.
+
 +++
 *** New option 'shr-discard-aria-hidden'.
 If set, shr will not render tags with attribute 'aria-hidden="true"'.
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 64cc1a51f6..f5a877f112 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -128,6 +128,13 @@ eww-use-external-browser-for-content-type
   :type '(choice (const :tag "Never" nil)
                  regexp))
 
+(defcustom eww-accept-content-types
+  "text/html, text/plain, text/sgml, text/css, application/xhtml+xml, */*;q=0.01"
+  "Value used for the HTTP Accept header."
+  :version "27.1"
+  :group 'eww
+  :type 'string)
+
 (defcustom eww-after-render-hook nil
   "A hook called after eww has finished rendering the buffer."
   :version "25.1"
@@ -282,8 +289,9 @@ eww
   (let ((inhibit-read-only t))
     (insert (format "Loading %s..." url))
     (goto-char (point-min)))
-  (url-retrieve url 'eww-render
-                (list url nil (current-buffer))))
+  (let ((url-mime-accept-string eww-accept-content-types))
+    (url-retrieve url 'eww-render
+                  (list url nil (current-buffer)))))
 
 (defun eww--dwim-expand-url (url)
   (setq url (string-trim url))
@@ -944,8 +952,9 @@ eww-reload
 	    (error "No current HTML data")
 	  (eww-display-html 'utf-8 url (plist-get eww-data :dom)
 			    (point) (current-buffer)))
-      (url-retrieve url 'eww-render
-		    (list url (point) (current-buffer) encode)))))
+      (let ((url-mime-accept-string eww-accept-content-types))
+        (url-retrieve url 'eww-render
+		      (list url (point) (current-buffer) encode))))))
 
 ;; Form support.
 
-- 
2.17.1