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

Chapter20 Web Server code problem #800

Open
dade68 opened this issue Jul 7, 2024 · 4 comments
Open

Chapter20 Web Server code problem #800

dade68 opened this issue Jul 7, 2024 · 4 comments

Comments

@dade68
Copy link

dade68 commented Jul 7, 2024

书的最后一章构建多线程服务器代码,测试发现浏览器第一连接发起请求,TcpListener会认为收到两个请求,发出两个消息,会有两个线程收到消息开始工作,只不过第二个因为没有实际的请求会阻塞到job那里,这时候在用浏览器发起一次请求,阻塞的那个线程才会实际开始工作,这是为什么啊?

@KaiserY
Copy link
Owner

KaiserY commented Jul 10, 2024

是不是浏览器发了俩请求?你直接 curl 试试?我看浏览器还会多请求一个 favicon

@dade68
Copy link
Author

dade68 commented Jul 11, 2024

用curl请求打印是正常的,看来是浏览器的请求比较复杂,另外问一下是怎么看到请求favicon的,我F12看network那里没看到这个。我试了先浏览器请求第一下,然后用curl请求第二下,curl无法建立连接,看来浏览器第一下是个类似长连接的,导致其他程序无法建立连接

@KaiserY
Copy link
Owner

KaiserY commented Jul 11, 2024

就是 F12,有时(感觉是新 tab 第一次)会出现,按 F5 就没有了。

@songchengen
Copy link

正常的,浏览器请求网站的时候,会默认发起网站图标的请求,路劲是/favicon.ico

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

3 participants