我想使用 url.el(特别是 url-http.el)以编程方式进行一些 REST 调用。 用户已经通过其他方式指定了凭据(但这只是轻微相关——我也想为未经身份验证的调用获得相同的行为)但在某些查询中我仍然可以获得 401(未经授权)响应。
我希望 url.el 顺其自然并返回 401 响应,而无需经过所有繁琐的询问用户(他们只会被再次询问而生气)。
注意:我手动创建了初始授权 header ,因此我没有使用 url-auth.el 中的任何工具(或它的名称)。
编辑:这似乎对我有用(Sacha 提供的解决方案):
(defvar *foobar-within-call* nil
"Helper variable to indicate if we are withing a foobar call and thus won't want the authentication mechanisms to kick in")
(defadvice url-http-handle-authentication (around foobar-fix)
(unless *foobar-within-call*
ad-do-it))
(ad-activate 'url-http-handle-authentication)
最佳答案
我想你可以添加一些关于 url-http-handle-authentication 的建议......
关于emacs - 如何使用 Emacs 的 url.el lib 而无需询问用户 401(未经授权)响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1486801/