From unknown Sun Aug 10 09:14:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#61916: 30.0.50; url.el; Can not change User-Agent temporarily when url-retrieve Resent-From: xhcoding Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Mar 2023 14:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61916 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 61916@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167776832724665 (code B ref -1); Thu, 02 Mar 2023 14:46:02 +0000 Received: (at submit) by debbugs.gnu.org; 2 Mar 2023 14:45:27 +0000 Received: from localhost ([127.0.0.1]:56252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXkBN-0006PY-J2 for submit@debbugs.gnu.org; Thu, 02 Mar 2023 09:45:26 -0500 Received: from lists.gnu.org ([209.51.188.17]:40012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXj7k-0004dx-9i for submit@debbugs.gnu.org; Thu, 02 Mar 2023 08:37:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXj7j-00021B-TR for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 08:37:31 -0500 Received: from out162-62-57-137.mail.qq.com ([162.62.57.137]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXj7g-0001wk-PP for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 08:37:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1677764235; bh=Z1VnxUR2Jq6tHtviFRmVilQHPOy8toREQzGcfpfILoQ=; h=Date:From:To:Subject; b=oT9/KViHtvUu9sVRw1Q4EI1EAb4ZpX4XxCZd4TXYHiAvBy1MB2Lbhy+4FK1RuO0jq QrKyCs9zScipoPXAtztFHXsSqBQSoqmQpOdlJQ7ZEOzyGWfU+7HMt1DuPF0Wo0jw/f AZjxXJzJkXbw/K66XDUHtACXmpN6J9wvkFGGGFjE= Received: from XHCODING-PC.qq.com ([39.128.4.18]) by newxmesmtplogicsvrszc2-1.qq.com (NewEsmtp) with SMTP id 94E2AA4A; Thu, 02 Mar 2023 21:37:14 +0800 X-QQ-mid: xmsmtpt1677764234t4culun8z Message-ID: X-QQ-XMAILINFO: OZsapEVPoiO6zwOjxU4FrQ5VBuutJBfG9xLob4sFQxM9ED7ff92Yd0Vsl+9FA7 MDeeWC0vt+kV9PFRFn2KdB/pmh+jZxgiZulMp24D1djRCEFF2qssfD2JOVP/WbqheoWdEjptPmUJ EwFfdMkLW9azcccaL/EEQkXiMLKpbvtYh6at8eiTfYJ7YYowGpjMayWQBHtVVjKu57CmTcZVgt15 C4equ/cgNw9W8iYrr1FzZ/0LdRBnAFkr/zgOJ+1TguFtsKRxmAuTyMN3pgcD9wxIOOONpX3NLV/g jGR0bQjAxHlNgVgzLokBM2Kb0XRdkL05GqJmaCjpabr28oeqLjy5m7xsbx0CP9X2M5jQuiB+lamz D7zjoib283EqJ8PG2VgTXrel2FtziXR7ixCskoP/kBQBCLCCdwoehlLEXD4CEHPm9/2F31Xpd/ys QkVjEp5BGgxcsgwC/RBKzkhrt+RAXKNc/I+DekaL+B6aMys0RossxaWhC5+6vETu7HPWjQmQkbR0 ih7fhD0WXRxuQ3UecAWOSXZQmEtp0vhqJmZBMb00PG689ZtzWByqKG6UHruRBhYRl2pcY1TYzTXO K5PelrJxPMoey+WLuuYgbZwsJ+0ChY2oQWF12giXw5P3nOcwBizdRpKCAySiKv9HsNQh1Rkhnn+4 nZCX8iRRq73/sAZ+093P0YTcIfIxT+BgEc3GGfd4iZ/5+N14ZvCq/RqsRckKXFDNOnh+at3vdgBw 1hAp2udqkI0TRhYasTQ/OA7pR6MeDktneb/ynyavTmCO3/KKJYTtxnpSQCLTe72QZZP27600x7nv 0N/wP3jz1kw6SkP2Edfk0xnR26KSE6WACy6OnjbCZhsytgQ/5uCshMlQ8UCrJDJh1ddkBEFRoW7T lkizI1YrZoTxJ0Wx67tLxJfEFCI/D92U0QBybFFRAW/2Qa76N2DgblQ9KqWB9nOqOBdLQ04fP+eO SIpVhRP407QqmtWpvH4VSfE3kO63XZ Date: Thu, 02 Mar 2023 21:37:13 +0800 X-OQ-MSGID: <86zg8vw9yu.wl-xhcoding@foxmail.com> From: xhcoding User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Received-SPF: pass client-ip=162.62.57.137; envelope-from=xhcoding@foxmail.com; helo=out162-62-57-137.mail.qq.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HELO_DYNAMIC_IPADDR=1.951, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Thu, 02 Mar 2023 09:45:19 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) The following code cannot be used to temporarily change User-Agent (require 'url) (setq url-debug t) (let ((url-user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57")) (url-retrieve "https://httpbin.org/get?a=b" (lambda (_)))) Because the url-retrieve is asynchronous, when the url-user-agent is actually used (eg. url-http-create-request be called), it may be out of the let scope. In GNU Emacs 30.0.50 (build 5, x86_64-w64-mingw32) Repository revision: 07a76a06f9a438e2a1bf1e565e3e78f7927c37f2 Repository branch: master Windowing system distributor 'Microsoft Corp.', version 10.0.22621 System Description: Microsoft Windows 10 Home China (v10.0.2009.22621.1105) Configured using: 'configure --prefix=/d/emacs-build/pkg/master-x86_64 'CFLAGS=-Ofast -fno-finite-math-only -fomit-frame-pointer' --with-zlib --with-xpm --with-xml2 --with-tree-sitter --without-tiff --with-rsvg --with-png --with-lcms2 --with-json --with-jpeg --with-harfbuzz --with-gnutls --with-gif --without-cairo --disable-build-details --without-dbus --with-compress-install --with-small-ja-dic' Configured features: ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB Important settings: value of $LANG: CHS locale-coding-system: cp936 Major mode: ELisp/d From unknown Sun Aug 10 09:14:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#61916: 30.0.50; url.el; Can not change User-Agent temporarily when url-retrieve Resent-From: "Peder O. Klingenberg" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Jul 2025 12:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61916 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: xhcoding Cc: 61916@debbugs.gnu.org Received: via spool by 61916-submit@debbugs.gnu.org id=B61916.175284350319655 (code B ref 61916); Fri, 18 Jul 2025 12:59:01 +0000 Received: (at 61916) by debbugs.gnu.org; 18 Jul 2025 12:58:23 +0000 Received: from localhost ([127.0.0.1]:33213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uckfP-00056x-1w for submit@debbugs.gnu.org; Fri, 18 Jul 2025 08:58:23 -0400 Received: from s17612523434.blix.com ([176.125.234.34]:44116 helo=castor.klingenberg.no) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uckfI-00056M-32; Fri, 18 Jul 2025 08:58:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=klingenberg.no; s=20200407; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Svb4xtra7UMrJBAuI+TpkFA+SvJjluTVIbEikna/oZw=; b=h5Cz0c/4ntSbmO3PfRO2SkISZ VZaZZUSFT8VsyccXylvrmp4+Jo4V1hajdZiqoe0sopqYVmCFOgh8TvhQGMDF1k0hcqIYLJmnOjTgp DQ15eidcS51CuSW2jeFgE/LWGylZsR3Ch1cGiAT3th7Dsejqe9bErN8TzbM1KebTs5oaL/zJ9jYhW l3RHhnf6O5Qjdu+QJQEBwG6JaIp+Qgcng89ZtPU+ZuXyqZFAZwIaJhB/uLRdlwKdjHMLYkrLFig/P U2LrtPnsrYAk6knDo3oRlh0BNOlGUp0TZOZ/XCXT9Q9xA0jjZrgxJJ1ymjFYp1HrwnmM+3YX1dSl/ kDaMbbb7Q==; Received: from 77.16.47.234.tmi.telenormobil.no ([77.16.47.234] helo=PedersHP) by castor.klingenberg.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uckfE-0008UJ-TD; Fri, 18 Jul 2025 14:58:13 +0200 From: "Peder O. Klingenberg" In-Reply-To: References: Date: Fri, 18 Jul 2025 14:57:58 +0200 Message-ID: <87ecudlkq1.fsf@klingenberg.no> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 61916 + patch quit On Thu, 2023-03-02 21:37:13 +0800, xhcoding wrote: > The following code cannot be used to temporarily change User-Agent > > (require 'url) > (setq url-debug t) > (let ((url-user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57")) > (url-retrieve "https://httpbin.org/get?a=b" (lambda (_)))) Some, but not all, variables used to construct a request by url-http.el have their dynamic values preserved in the buffer used for the async communication. url-user-agent was not among the so blessed. For the unlucky variables, the behaviour is extra confusing because connections are sometimes re-used (due to http keep-alive), in which case the dynamic bindings _do_ work as expected. This same issue hit me as I was working on improving restclient.el, where some of the bug reports probably originate from this confusing behaviour of url-http.el. Attached is a patch that extends the set of dynamic-values-at-call-time -> buffer-local-available-at-request-time variables. With this, your test case works as expected, as do my experiments in restclient. Hopefully this will be picked up by someone with commit privileges. -- ...Peder... From unknown Sun Aug 10 09:14:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#61916: 30.0.50; url.el; Can not change User-Agent temporarily when url-retrieve Resent-From: "Peder O. Klingenberg" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Jul 2025 13:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61916 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: xhcoding Cc: 61916@debbugs.gnu.org Received: via spool by 61916-submit@debbugs.gnu.org id=B61916.175284383732152 (code B ref 61916); Fri, 18 Jul 2025 13:04:02 +0000 Received: (at 61916) by debbugs.gnu.org; 18 Jul 2025 13:03:57 +0000 Received: from localhost ([127.0.0.1]:33232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uckkm-0008MS-2i for submit@debbugs.gnu.org; Fri, 18 Jul 2025 09:03:56 -0400 Received: from s17612523434.blix.com ([176.125.234.34]:56014 helo=castor.klingenberg.no) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uckkj-0008MB-So for 61916@debbugs.gnu.org; Fri, 18 Jul 2025 09:03:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=klingenberg.no; s=20200407; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FdMmQGEYtpV7oiwHxWoLMn3IkS+fdcEUP9ryvee94XQ=; b=VFWiQ8ceGSllrdEQx2uMhvv0y esDZ9FQFFVU8mBoeN6vtEE0a9L5AmbPuD8qBJhG+jojVCDCVjmSLUq9iCcis0ejdV5ATZR4j9IVB8 8v3kxz8uPHb1UpjSEyE7lhLGC2n000/frZSeZv7xR6DN7E9TiC2HolujeWkZyBdBlDRmNi/ewiAex Rn0dEwIw+l4FIdWG+NuNaT2UDbBclgL4gUFEp4+Bk0KtFzlueQt2pwZdyImebTFiULb76uouzsuIe 9PhGlmYpflsLpA4x3WI5oPwhZtWQUivmVyF9P9aXwjLZUdRSpGwQ2QKOaxty7/f6hdvrpfpOC1e6s bs+8SWJGA==; Received: from 77.16.47.234.tmi.telenormobil.no ([77.16.47.234] helo=PedersHP) by castor.klingenberg.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uckki-00007U-1r; Fri, 18 Jul 2025 15:03:52 +0200 From: "Peder O. Klingenberg" In-Reply-To: <87ecudlkq1.fsf@klingenberg.no> References: <87ecudlkq1.fsf@klingenberg.no> Date: Fri, 18 Jul 2025 15:03:49 +0200 Message-ID: <87bjphlkga.fsf@klingenberg.no> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain On Fri, 2025-07-18 14:57:58 +0200, Peder O. Klingenberg wrote: > Attached is a patch that extends the set of dynamic-values-at-call-time > -> buffer-local-available-at-request-time variables. With this, your > test case works as expected, as do my experiments in restclient. (Except I failed to attach the patch using the debbugs-gnu-pick-commits command, so here, attached the old-fashioned way) -- ...Peder... --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Emulate-more-dynamic-bindings-in-request-buffers.patch >From a077e45a1cd9003f6255b0817d2182a431c7cd59 Mon Sep 17 00:00:00 2001 From: "Peder O. Klingenberg" Date: Fri, 18 Jul 2025 00:11:57 +0200 Subject: [PATCH] Emulate more dynamic bindings in request buffers Many variables were copied from the dynamic environment to the request buffer, which allowed them to influence the handling of requests and responses. But some were not, notably some of the mime-related variables, and the user-agent and privacy variables. This made them unreliable when dynamically bound around a call to `url-retrieve'; they would have the desired effect when reusing an existing connection, but not when url-http opened a new connection. In the case of reused connections, the request construction happens in the dynamic scope of `url-http', but in the case where a fresh connection is needed, request construction happens outside that dynamic scope. This commit adds the remaining variables used in request construction to the set of buffer local variables mirroring the dynamic values from url-http, and adds a comment describing the mechanism used and how avoid the pitfall of inconsistent handling of dynamic bindings. * lisp/url/url-http.el (url-http-extensions-header): New internal-ish variable. (url-http-create-request): Use the new variable instead of the global one. (url-http-idle-sentinel): Debug-log when the connection closes. (url-http): Set up more buffer-local variants of dynamic variables in the buffer used for the request, and add comment describing why this copying is needed. (Bug#61916) --- lisp/url/url-http.el | 51 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index eb5d5c13722..a230a37e9ff 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -56,6 +56,7 @@ url-http-target-url (defvar url-http-transfer-encoding) (defvar url-show-status) (defvar url-http-referer) +(defvar url-http-extensions-header) (require 'url-gw) (require 'url-parse) @@ -374,9 +375,9 @@ url-http-create-request "close" "keep-alive") "\r\n" ;; HTTP extensions we support - (if url-extensions-header + (if url-http-extensions-header (format - "Extension: %s\r\n" url-extensions-header)) + "Extension: %s\r\n" url-http-extensions-header)) ;; Who we want to talk to (if (/= (url-port url-http-target-url) (url-scheme-get-property @@ -1020,8 +1021,9 @@ url-http-activate-callback ;; ) ;; These unfortunately cannot be macros... please ignore them! -(defun url-http-idle-sentinel (proc _why) +(defun url-http-idle-sentinel (proc why) "Remove (now defunct) process PROC from the list of open connections." + (url-http-debug "url-http-idle-sentinel for process %S: %s" proc (string-trim why)) (maphash (lambda (key val) (if (memq proc val) (puthash key (delq proc val) url-http-open-connections))) @@ -1340,9 +1342,19 @@ url-http The return value of this function is the retrieval buffer." (cl-check-type url url "Need a pre-parsed URL.") + ;; The request is handled by asynchronous processes, which are outside + ;; the dynamic scope of the caller of url-http (sometimes, sometimes + ;; not). The caller may still desire to bind variables controlling + ;; aspects of the request for the duration of this one http request. + ;; The async processes operate on a buffer created in this function, + ;; so the way to accomplish this goal is to set buffer local copies of + ;; the relevant variables to the dynamic values in scope as we create + ;; the buffer. When new variables are added that influence behaviour + ;; of requests, they should be added to the handling in this function + ;; to make them work reliably without changing their global values. (let* (;; (host (url-host (or url-using-proxy url))) ;; (port (url-port (or url-using-proxy url))) - (nsm-noninteractive (not (url-interactive-p))) + (noninteractive-p (not (url-interactive-p))) ;; The following binding is needed in url-open-stream, which ;; is called from url-http-find-free-connection. (url-current-object url) @@ -1350,10 +1362,17 @@ url-http (url-port url) gateway-method)) (mime-accept-string url-mime-accept-string) + (mime-encoding-string url-mime-encoding-string) + (mime-charset-string url-mime-charset-string) + (mime-language-string url-mime-language-string) (buffer (or retry-buffer (generate-new-buffer (format " *http %s:%d*" (url-host url) (url-port url))))) - (referer (url-http--encode-string (url-http--get-referer url)))) + (referer (url-http--encode-string (url-http--get-referer url))) + (httpver url-http-version) + (httpkeepalive url-http-attempt-keepalives) + (user-agent url-user-agent) + (privacy-level url-privacy-level)) (if (not connection) ;; Failed to open the connection for some reason (progn @@ -1389,8 +1408,17 @@ url-http url-http-no-retry url-http-connection-opened url-mime-accept-string + url-mime-encoding-string + url-mime-charset-string + url-mime-language-string url-http-proxy - url-http-referer)) + url-http-referer + url-http-version + url-http-attempt-keepalives + url-http-extensions-header + url-user-agent + url-privacy-level + nsm-noninteractive)) (set (make-local-variable var) nil)) (setq url-http-method (or url-request-method "GET") @@ -1409,8 +1437,17 @@ url-http url-http-no-retry retry-buffer url-http-connection-opened nil url-mime-accept-string mime-accept-string + url-mime-encoding-string mime-encoding-string + url-mime-charset-string mime-charset-string + url-mime-language-string mime-language-string url-http-proxy url-using-proxy - url-http-referer referer) + url-http-referer referer + url-http-version httpver + url-http-attempt-keepalives httpkeepalive + url-http-extensions-header url-extensions-header + url-user-agent user-agent + url-privacy-level privacy-level + nsm-noninteractive noninteractive-p) (set-process-buffer connection buffer) (set-process-filter connection #'url-http-generic-filter) -- 2.25.1 --=-=-=-- From unknown Sun Aug 10 09:14:56 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: xhcoding Subject: bug#61916: closed (Re: bug#61916: 30.0.50; url.el; Can not change User-Agent temporarily when url-retrieve) Message-ID: References: <86jz3v1flc.fsf@gnu.org> X-Gnu-PR-Message: they-closed 61916 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 61916@debbugs.gnu.org Date: Sat, 26 Jul 2025 09:12:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1753521122-10156-1" This is a multi-part message in MIME format... ------------=_1753521122-10156-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #61916: 30.0.50; url.el; Can not change User-Agent temporarily when url-ret= rieve which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 61916@debbugs.gnu.org. --=20 61916: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D61916 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1753521122-10156-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 61916-done) by debbugs.gnu.org; 26 Jul 2025 09:11:55 +0000 Received: from localhost ([127.0.0.1]:39882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ufawc-0002dB-HD for submit@debbugs.gnu.org; Sat, 26 Jul 2025 05:11:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34892) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ufawa-0002cf-8L for 61916-done@debbugs.gnu.org; Sat, 26 Jul 2025 05:11:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufawU-0001To-0O; Sat, 26 Jul 2025 05:11:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=9knu9fdKKWbJV04HPZ3NUSAB28ohupmP25jlK3ij3Gs=; b=UoFwUhLWBbAW +2N0vZA4SseUtCWk0J9swyds9wLMLIdjvQvTZe1n4HKZ0U6sU/3E7ZQd1n7/2DTFWlbQwP8BmDDnn Bhhwk1w4gKIHvEMCJG5/GF+IDqS94iXItW5JqDDkMuXEpCukmAJ3wRRbCltwiM0n399iOzyc1ROec +YTtMVUrhP7GBMaVYUVnWLElkZJLz4TXOGAYvug6z0kz0aI5mvjSMx+teT1siSkqYtdNX92z/x+v0 DduAIwgjuwwEGhzp2lAJKG8f6+WceA8PA0VD496abAE/wBx9Gd9nSpuZVqHek8FH1PJ9f9lPRJ7XF 5rwAeSe8cU76X3dFZMtNOQ==; Date: Sat, 26 Jul 2025 12:11:43 +0300 Message-Id: <86jz3v1flc.fsf@gnu.org> From: Eli Zaretskii To: "Peder O. Klingenberg" In-Reply-To: <87bjphlkga.fsf@klingenberg.no> (peder@klingenberg.no) Subject: Re: bug#61916: 30.0.50; url.el; Can not change User-Agent temporarily when url-retrieve References: <87ecudlkq1.fsf@klingenberg.no> <87bjphlkga.fsf@klingenberg.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61916-done Cc: xhcoding@foxmail.com, 61916-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 61916@debbugs.gnu.org > From: "Peder O. Klingenberg" > Date: Fri, 18 Jul 2025 15:03:49 +0200 > > On Fri, 2025-07-18 14:57:58 +0200, Peder O. Klingenberg wrote: > > > Attached is a patch that extends the set of dynamic-values-at-call-time > > -> buffer-local-available-at-request-time variables. With this, your > > test case works as expected, as do my experiments in restclient. > > (Except I failed to attach the patch using the debbugs-gnu-pick-commits > command, so here, attached the old-fashioned way) Thanks, installed on the master branch, and closing the bug. ------------=_1753521122-10156-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 2 Mar 2023 14:45:27 +0000 Received: from localhost ([127.0.0.1]:56252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXkBN-0006PY-J2 for submit@debbugs.gnu.org; Thu, 02 Mar 2023 09:45:26 -0500 Received: from lists.gnu.org ([209.51.188.17]:40012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXj7k-0004dx-9i for submit@debbugs.gnu.org; Thu, 02 Mar 2023 08:37:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXj7j-00021B-TR for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 08:37:31 -0500 Received: from out162-62-57-137.mail.qq.com ([162.62.57.137]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXj7g-0001wk-PP for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 08:37:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1677764235; bh=Z1VnxUR2Jq6tHtviFRmVilQHPOy8toREQzGcfpfILoQ=; h=Date:From:To:Subject; b=oT9/KViHtvUu9sVRw1Q4EI1EAb4ZpX4XxCZd4TXYHiAvBy1MB2Lbhy+4FK1RuO0jq QrKyCs9zScipoPXAtztFHXsSqBQSoqmQpOdlJQ7ZEOzyGWfU+7HMt1DuPF0Wo0jw/f AZjxXJzJkXbw/K66XDUHtACXmpN6J9wvkFGGGFjE= Received: from XHCODING-PC.qq.com ([39.128.4.18]) by newxmesmtplogicsvrszc2-1.qq.com (NewEsmtp) with SMTP id 94E2AA4A; Thu, 02 Mar 2023 21:37:14 +0800 X-QQ-mid: xmsmtpt1677764234t4culun8z Message-ID: X-QQ-XMAILINFO: OZsapEVPoiO6zwOjxU4FrQ5VBuutJBfG9xLob4sFQxM9ED7ff92Yd0Vsl+9FA7 MDeeWC0vt+kV9PFRFn2KdB/pmh+jZxgiZulMp24D1djRCEFF2qssfD2JOVP/WbqheoWdEjptPmUJ EwFfdMkLW9azcccaL/EEQkXiMLKpbvtYh6at8eiTfYJ7YYowGpjMayWQBHtVVjKu57CmTcZVgt15 C4equ/cgNw9W8iYrr1FzZ/0LdRBnAFkr/zgOJ+1TguFtsKRxmAuTyMN3pgcD9wxIOOONpX3NLV/g jGR0bQjAxHlNgVgzLokBM2Kb0XRdkL05GqJmaCjpabr28oeqLjy5m7xsbx0CP9X2M5jQuiB+lamz D7zjoib283EqJ8PG2VgTXrel2FtziXR7ixCskoP/kBQBCLCCdwoehlLEXD4CEHPm9/2F31Xpd/ys QkVjEp5BGgxcsgwC/RBKzkhrt+RAXKNc/I+DekaL+B6aMys0RossxaWhC5+6vETu7HPWjQmQkbR0 ih7fhD0WXRxuQ3UecAWOSXZQmEtp0vhqJmZBMb00PG689ZtzWByqKG6UHruRBhYRl2pcY1TYzTXO K5PelrJxPMoey+WLuuYgbZwsJ+0ChY2oQWF12giXw5P3nOcwBizdRpKCAySiKv9HsNQh1Rkhnn+4 nZCX8iRRq73/sAZ+093P0YTcIfIxT+BgEc3GGfd4iZ/5+N14ZvCq/RqsRckKXFDNOnh+at3vdgBw 1hAp2udqkI0TRhYasTQ/OA7pR6MeDktneb/ynyavTmCO3/KKJYTtxnpSQCLTe72QZZP27600x7nv 0N/wP3jz1kw6SkP2Edfk0xnR26KSE6WACy6OnjbCZhsytgQ/5uCshMlQ8UCrJDJh1ddkBEFRoW7T lkizI1YrZoTxJ0Wx67tLxJfEFCI/D92U0QBybFFRAW/2Qa76N2DgblQ9KqWB9nOqOBdLQ04fP+eO SIpVhRP407QqmtWpvH4VSfE3kO63XZ Date: Thu, 02 Mar 2023 21:37:13 +0800 X-OQ-MSGID: <86zg8vw9yu.wl-xhcoding@foxmail.com> From: xhcoding To: bug-gnu-emacs@gnu.org Subject: 30.0.50; url.el; Can not change User-Agent temporarily when url-retrieve User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Received-SPF: pass client-ip=162.62.57.137; envelope-from=xhcoding@foxmail.com; helo=out162-62-57-137.mail.qq.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HELO_DYNAMIC_IPADDR=1.951, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 02 Mar 2023 09:45:19 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) The following code cannot be used to temporarily change User-Agent (require 'url) (setq url-debug t) (let ((url-user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57")) (url-retrieve "https://httpbin.org/get?a=b" (lambda (_)))) Because the url-retrieve is asynchronous, when the url-user-agent is actually used (eg. url-http-create-request be called), it may be out of the let scope. In GNU Emacs 30.0.50 (build 5, x86_64-w64-mingw32) Repository revision: 07a76a06f9a438e2a1bf1e565e3e78f7927c37f2 Repository branch: master Windowing system distributor 'Microsoft Corp.', version 10.0.22621 System Description: Microsoft Windows 10 Home China (v10.0.2009.22621.1105) Configured using: 'configure --prefix=/d/emacs-build/pkg/master-x86_64 'CFLAGS=-Ofast -fno-finite-math-only -fomit-frame-pointer' --with-zlib --with-xpm --with-xml2 --with-tree-sitter --without-tiff --with-rsvg --with-png --with-lcms2 --with-json --with-jpeg --with-harfbuzz --with-gnutls --with-gif --without-cairo --disable-build-details --without-dbus --with-compress-install --with-small-ja-dic' Configured features: ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB Important settings: value of $LANG: CHS locale-coding-system: cp936 Major mode: ELisp/d ------------=_1753521122-10156-1--