unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Federico Tedin <federicotedin@gmail.com>
To: John Smith <winston@ml1.net>
Cc: 33002@debbugs.gnu.org
Subject: bug#33002: 26.1; EWW sends unspecific "Accept: */*" header
Date: Sun, 4 Nov 2018 00:15:38 -0300	[thread overview]
Message-ID: <CAA8GjPmWbkW11+ZzHLze+KkFsEM-us33-9h9iERipOTyJBEDBA@mail.gmail.com> (raw)
In-Reply-To: <CAA8GjPnVe8xPr6rCTKdL52oBV5sRrwEgfmX0PB8XMUtOxwCwkw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 204 bytes --]

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.

[-- Attachment #2: eww.patch --]
[-- Type: text/x-patch, Size: 2504 bytes --]

From b2fe312aa5232fa3cfc259feb3cf313ae85faa9b Mon Sep 17 00:00:00 2001
From: Federico Tedin <federicotedin@gmail.com>
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


  reply	other threads:[~2018-11-04  3:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10  5:11 bug#33002: 26.1; EWW sends unspecific "Accept: */*" header Winston Weinert
2018-10-13 21:59 ` Federico Tedin
2018-11-04  3:15   ` Federico Tedin [this message]
2018-11-04 17:27     ` Eli Zaretskii
2018-11-04 18:29       ` Federico Tedin
2018-11-13 21:26         ` Federico Tedin
2018-11-14  3:31           ` Eli Zaretskii
2019-05-13 18:08             ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA8GjPmWbkW11+ZzHLze+KkFsEM-us33-9h9iERipOTyJBEDBA@mail.gmail.com \
    --to=federicotedin@gmail.com \
    --cc=33002@debbugs.gnu.org \
    --cc=winston@ml1.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).