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)