3
Go 的 http 服务器,同时下载的连接不能超过两个吗?
source link: https://www.v2ex.com/t/858651
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.
一个最简单的 http 服务器:
func main() {
fs := http.FileServer( http.Dir("./public"))
http.Handle("/", fs)
http.ListenAndServe(":8888", nil)
}
用 curl 测试几个连接同时下载:
curl --limit-rate 1k http://1.2.3.4:9999/file.zip --output NUL
结果是,只有第一个和第二个连接正常下载,其他的连接处于停滞状态,只有前面的连接下载完了,后面的才能接着下载。
如果把服务器换成 nginx 则多个连接都可以同时下载。
以上都是在 Windows 11 下进行的 Go 的版本是 1.18.1
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK