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

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

> Does it really make sense to make this a customizable option?  How
> would an average user choose a value for this option?
>
> I think EWW should decide by itself what header to send.

I agree, it is not something most people will want to change. If they
really want to change it though, they can just do (setq
eww-accept-content-types ...). I've changed the patch to use defvar
instead of defcustom.
From e6730701f320cf65ab02c8d550a442d3e4ea3c25 Mon Sep 17 00:00:00 2001
From: Federico Tedin <[email-masked]>
Date: Sun, 4 Nov 2018 15:24:36 -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.
---
 lisp/net/eww.el | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 64cc1a51f6..0c3fe8f7b3 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -223,6 +223,10 @@ eww-prompt-history
 (defvar eww-local-regex "localhost"
   "When this regex is found in the URL, it's not a keyword but an address.")
 
+(defvar 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.")
+
 (defvar eww-link-keymap
   (let ((map (copy-keymap shr-map)))
     (define-key map "\r" 'eww-follow-link)
@@ -282,8 +286,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 +949,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