2

使用 CORS 从 JavaScript 访问 Google Drive 上文件的字节范围时遇到问题。

它大部分都可以正常工作(道具!),但我的应用程序希望在部分响应中查看 Content-Range 标头以了解文件的总长度,但我不允许从 XMLHttpRequest 获取它,因为它未在响应的“access-control-expose-headers”标头中列出。

我可以通过使用文件元数据中的大小(我已经获取以获取下载 URL)中的大小来解决这个问题,但是如果有人来自 Drive,将 Content-Range 包含在 access-control-expose-headers 中会很好API 开发团队阅读此内容。

来自 Chrome devtools 的示例请求转储:

Request URL: https://doc-0g-38-docs.googleusercontent.com/docs/securesc/6evfs70tsp1qa1i52rjh8oirj2t88vrd/rve4p35jans7cojv8fbj68flmsm51clj/1380672000000/00355094596910024248/00355094596910024248/0B0-hjEIqYxjYUDF3dDhxNndpd0U?h=16653014193614665626&e=download&gd=true

请求方法: GET

状态码: 206 部分内容

请求标头

:host:doc-0g-38-docs.googleusercontent.com
:method:GET
:path:/docs/securesc/6evfs70tsp1qa1i52rjh8oirj2t88vrd/rve4p35jans7cojv8fbj68flmsm51clj/1380672000000/00355094596910024248/00355094596910024248/0B0-hjEIqYxjYUDF3dDhxNndpd0U?h=16653014193614665626&e=download&gd=true
:scheme:https
:version:HTTP/1.1
accept:*/*
accept-encoding:gzip,deflate,sdch
accept-language:en-US,en;q=0.8
authorization:Bearer ya29.AHES6ZSEzaPW_sYd4BaKNnlD-l73ZDy0XIS-cJlfX_LOT1qR
cache-control:no-cache
origin:http://jbrowse.org:8080
pragma:no-cache
range:bytes=0-65535
referer:http://jbrowse.org:8080/jbrowse/index.html?highlight=&dataRoot=newvolvox
user-agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
Query String Parametersview sourceview URL encoded
h:16653014193614665626
e:download
gd:true

响应标头

access-control-allow-credentials:false
access-control-allow-headers:Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, Content-Type, Date, GData-Version, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, X-ClientDetails, X-GData-Client, X-GData-Key, X-Goog-AuthUser, X-Goog-Encode-Response-If-Executable, X-Goog-Correlation-Id, X-Goog-Upload-Command, X-Goog-Upload-Content-Disposition, X-Goog-Upload-Content-Length, X-Goog-Upload-Content-Type, X-Goog-Upload-Offset, X-Goog-Upload-Protocol, X-Goog-Visitor-Id, X-HTTP-Method-Override, X-JavaScript-User-Agent, X-Origin, X-Referer, X-Upload-Content-Length, X-Upload-Content-Type, X-Use-HTTP-Status-Code-Override, X-YouTube-VVT, X-YouTube-Page-CL, X-YouTube-Page-Timestamp
access-control-allow-methods:GET,OPTIONS
access-control-allow-origin:*
access-control-expose-headers:Cache-Control, Content-Length, Date, Expires, Server, Transfer-Encoding
alternate-protocol:443:quic
cache-control:private, max-age=0
content-disposition:attachment;filename="volvox-sorted.bam";filename*=UTF-8''volvox-sorted.bam
content-length:65536
content-range:bytes 0-65535/395273
content-type:application/x-gzip
date:Wed, 02 Oct 2013 01:49:09 GMT
expires:Wed, 02 Oct 2013 01:49:09 GMT
server:HTTP Upload Server Built on Sep 30 2013 10:58:35 (1380563915)
status:206 Partial Content
version:HTTP/1.1
4

0 回答 0