]> git.eshelyaron.com Git - emacs.git/commit
Emulate more dynamic bindings in request buffers
authorPeder O. Klingenberg <peder@klingenberg.no>
Thu, 17 Jul 2025 22:11:57 +0000 (00:11 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 26 Jul 2025 15:23:48 +0000 (17:23 +0200)
commitb18bad616d2b4f84e9fb4998e3cba9cc0f1bba01
tree1c6103821c3f68200b4cfb935132e7fac9823a31
parent9780adf440bb93f7ffca2c7a9047fe92056c18e8
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)

(cherry picked from commit a2d71cecaec1aa16bbbef54e5231ba203e7d2a2a)
lisp/url/url-http.el