比如我们的论坛,url.el
会自动重定向,curl
不会,需要自己加 -L
/ --location
才会
(display-buffer
(url-retrieve-synchronously
"http://emacs-china.org"))
curl -v emacs-china.org
curl -vL emacs-china.org
有没有办法让 url.el
不自动重定向呢?
我写了个 curl 命令转 elisp 代码的包,好奇如何处理没有 -L
的情况。
cireu
2
(let ((url-max-redirections 0))
(display-buffer
(url-retrieve-synchronously
"http://emacs-china.org")))
Response body
HTTP/1.1 301 Moved Permanently
Server: nginx/1.17.4
Date: Thu, 05 Mar 2020 15:23:49 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive
Location: https://emacs-china.org/
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.17.4</center>
</body>
</html>
1 个赞