Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一定要discard headers么? #13

Open
vmjie opened this issue Mar 29, 2017 · 4 comments
Open

一定要discard headers么? #13

vmjie opened this issue Mar 29, 2017 · 4 comments

Comments

@vmjie
Copy link

vmjie commented Mar 29, 2017

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是一定需要的么?

@liuyunbin
Copy link

在 HTTP 请求报文中,请求行,请求头部,空行都是必有的,如果不读取,会留在缓存区吧。

@lanthree
Copy link

@liuyunbin 后面就是close了,close不会丢掉缓存区吗?

@linzewei1991
Copy link

mark

@hellowack
Copy link

@liuyunbin 后面就是close了,close不会丢掉缓存区吗?

我觉得是不是因为考虑到,后续会有其他请求,这里将缓冲区读完,避免缓冲区内容堆积呢?纯属猜测😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants