5

url-http-end-of-headers

 3 years ago
source link: https://www.lujun9972.win/blog/2019/04/30/url-http-end-of-headers/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

url-http-end-of-headers

使用 url 包来获取网页内容时,经常要做的一个步骤就是跳过HTTP headers。之前我都是通过搜索空行的方式来实现

(re-search-forward "^$")

但是实际上 url-http 在获取网页内容后,会设置一个名为 url-http-end-of-headers 的marker,我们可以直接通过该maker来跳过HTTP headers。

(goto-char url-http-end-of-headers)

大致的顺序为:

  1. url-http 函数使用 url-http-generic-filter 作为 process filter,
  2. url-http-generic-filter 中调用变量 url-http-after-change-function 中定义的函数
  3. 在这些 change-function 的函数中会调用通过搜索正则表达式 ^$ 来设置标记

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK