Tinyhttpd
Tinyhttpd copied to clipboard
一定要discard headers么?
sprintf(path, "htdocs%s", url);
if (path[strlen(path) - 1] == '/')
strcat(path, "index.html");
if (stat(path, &st) == -1) {
while ((numchars > 0) && strcmp("\n", buf)) /* read & discard headers */
numchars = get_line(client, buf, sizeof(buf));
not_found(client);
}
这里discard headers是一定需要的么?
在 HTTP 请求报文中,请求行,请求头部,空行都是必有的,如果不读取,会留在缓存区吧。
@liuyunbin 后面就是close了,close不会丢掉缓存区吗?
mark
@liuyunbin 后面就是close了,close不会丢掉缓存区吗?
我觉得是不是因为考虑到,后续会有其他请求,这里将缓冲区读完,避免缓冲区内容堆积呢?纯属猜测😂