HTML 5视频部分内容和err_connection_reset

时间:2018-11-01 21:02:41

标签: javascript html5 google-chrome html5-video

我正在从Javascript加载HTML5视频,并对Chrome中的某些行为感到好奇。

当我加载视频时,我在使用部分下载时看到4个不同的请求。请求1,2和4看起来都有效,位请求3失败,并出现net :: ERR_CONNECTION_RESET 206(部分内容)。

我加载视频的代码如下:

const filename = '<some url on AWS S3>';
let vid = document.getElementById('video');
video.setAttribute('src', filename);
video.onerror = function (event) {
  handleError(event, 0, 0, streamData);
};
video.setAttribute('crossorigin', 'anonymous');

请求和响应如下:

请求1:

Request URL: https://xxx.s3.amazonaws.com/videos/20180816.mp4?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXX%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20181101T200929Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Signature=XXXX
Request Method: GET
Status Code: 206 Partial Content
Remote Address: 52.216.169.19:443
Referrer Policy: no-referrer-when-downgrade

响应1:

Accept-Ranges: bytes
Access-Control-Allow-Methods: GET
Access-Control-Allow-Origin: *
Content-Length: 144276001
Content-Range: bytes 0-144276000/144276001
Content-Type: video/mp4
Date: Thu, 01 Nov 2018 20:09:31 GMT
ETag: "084e2d8fd0986b80d8be431fee276a52-9"
Last-Modified: Thu, 01 Nov 2018 20:01:27 GMT
Server: AmazonS3
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
x-amz-id-2: iIKndrRGB7Ov+c9w2M8gCFlGP3kiUIj3jv189N1o+uZUdIoqMlPL3yXHjWirmA3WZJod+t4NkX8=
x-amz-meta-content-duration: 1425
x-amz-request-id: BD4FBA30398AB1D7
x-amz-server-side-encryption: AES256

请求#1请求标头:

Accept-Encoding: identity;q=1, *;q=0
chrome-proxy: frfr
Origin: https://mysite.test
Range: bytes=0-
Referer: https://mysite.test/showvideo/18
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36

请求2: 看起来与请求1相同,但内容长度和范围不同:

Content-Length: 293409
Content-Range: bytes 143982592-144276000/144276001

请求#2请求标头 没有铬代理,范围是

Range: bytes=143982592-

请求3不同,总是失败:

请求3:

Request URL: https://xxx.s3.amazonaws.com/videos/20180816.mp4?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXX%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20181101T200929Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Signature=XXXX
Referrer Policy: no-referrer-when-downgrade

*请求#3标头:” 与请求2相同,除了:

Range: bytes=32768-

最后,请求4看起来像请求2,但字节范围不同。

这是怎么回事?为什么第三个请求在Chrome中重置连接后总是失败?

我只是迅速检查了一下,Firefox没有表现出这种行为。

0 个答案:

没有答案