TheWaWaR / simple-http-server

Simple http server in Rust (Windows/Mac/Linux)
MIT License
2.63k stars 175 forks source link

range以及编码问题 #107

Closed yoshyv closed 7 months ago

yoshyv commented 7 months ago

你好

想请教下以下两个问题。 环境: macOS 14.3.1 (本地) Debian 12.4 (远程)


range支持问题 测试了下在服务端放测试文件 test.ts

用 VLC macOS 播放,能正常打开,但是拖动进度条时候会报错 HTTP 416,播放退出。

[2024-03-03 20:33:25] - [IP] - 206 - GET /.ts
[2024-03-03 20:33:28] - [IP] - 416 - GET /test.ts

用 IINA 播放。能正常打开,能拖动进度条,但是会反复请求 range。加载半分钟后,正常从进度条拖动位置开始继续播放。

[2024-03-03 20:47:51] - [IP] - 206 - GET /test.ts
[2024-03-03 20:47:53] - [IP] - 206 - GET /test.ts
[2024-03-03 20:47:54] - [IP] - 206 - GET /test.ts
... (十几个同样请求)

(反复请求可能是 IINA mpv 处理 ts 容器的问题。mp4 封装的话拖动进度条后只有一次请求)

请问是否能检查下 VLC 播放情况下拖动进度条问题呢?(播放任意封装/编码,拖动进度条都会416报错)


编码处理问题

经测试,发现 yt-dlp 下载的所有视频。用 IINA 播放会报错 HTTP 404 [2024-03-03 20:57:49] - [IP] - 404 - GET /Sample%20Breakdown%EF%BC%9A%20Daft%20Punk%20-%20Discovery%20[5AqHSvR9bqs].mp4

对比 python http simple server 和 RangeHTTPServer 发现,是 IINA 处理方括号问题。 为了避免类似错误是否能把 [] 处理成 %5B %5D 呢。

谢谢

TheWaWaR commented 7 months ago

https://github.com/TheWaWaR/simple-http-server/releases/tag/v0.6.9 最新版中解决了编码的问题。

TheWaWaR commented 7 months ago

416 Range Not Satisfiable 猜测是 VLC 给的 range 不对

yoshyv commented 7 months ago

感谢更新。 如果 VLC 给的 range 不对的话其他 http server 应该也有同样问题? 实测 nginx 和 RangeHTTPServer 都没有这个问题。

yoshyv commented 5 months ago

@TheWaWaR

看起来 VLC 是用 head 请求判断文件大小。用 curl 测试返回 Content-Length: 0

curl URL -I
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Type: text/plain
Content-Length: 0
Cache-Control: public, max-age=604800
Last-Modified: Tue, 23 Apr 2024 04:09:14 GMT
ETag: W/"436f0fd08-6627346a.0"
Date: Tue, 23 Apr 2024 08:23:48 GMT

和这个 issue 应该是一个问题。 https://github.com/TheWaWaR/simple-http-server/issues/16