aardio 文档

inet.httpRange 库模块帮助文档

» inet.httpRange 使用指南 » 相关库: wsock.tcp.httpRange

inet.httpRange 成员列表 #

固定长度二进制表示的 HTTP 单 Range 工具与严格随机范围读取源。用 HTTP 随机范围读取远程资源,与媒体格式无关。

inet.httpRange.openSource() #

返回对象:httpRangeSourceObject

inet.httpRange.openSource(spec) #

创建同步随机读取源,成功返回对象,失败返回 null,err;创建不联网。
必填 url、size;可选 etag、expiresAt、headers、userAgent、referer、proxy、connectTimeout、requestTimeout、receiveTimeout、maxReadBytes、maxRedirects、allowHttp、allowCrossOriginRedirects、isCancelled、validateUrl。
默认 HTTPS/系统证书校验;read 才发送精确单 Range GET;不重试、不缓存、不探测长度。详见指南。

inet.httpRange.parse() #

返回对象:httpByteRangeObject

inet.httpRange.parse(header,total) #

解析单个 bytes=start-end、bytes=start-、bytes=-suffix;total 为已知总字节数。
偏移从 0 开始,end 包含端点。无头返回 status=200;可满足返回 206;越界返回 416;语法无效或多 Range 返回 null,err。整数不超过 2^53-1。

inet.httpRange.parseContentRange() #

返回对象:httpByteRangeObject

inet.httpRange.parseContentRange(header) #

解析已知总长度的 Content-Range:bytes start-end/total 或 bytes */total。成功返回含 total 的表;失败返回 null,err。不支持未知总长度 *。

inet.httpRange.slice(data,range) #

从字符串或 buffer 截取 parse 返回的 200/206 范围,返回 buffer;空范围返回零长度 buffer;无效参数返回 null,err。

httpByteRangeObject 成员列表 #

httpByteRangeObject.contentRange #

可发送的 Content-Range(206/416)。

httpByteRangeObject.end #

包含端点的末字节偏移;空表示为 -1(200/206)。

httpByteRangeObject.length #

所选字节数(200/206)。

httpByteRangeObject.start #

从 0 开始的首字节偏移(200/206)。

httpByteRangeObject.status #

200、206 或 416。

httpByteRangeObject.total #

parseContentRange 返回的总字节数。

httpRangeSourceObject 成员列表 #

httpRangeSourceObject.close() #

标记源关闭,幂等。后续 read 返回 null,SOURCE_CLOSED;不保留长连接。
取消、期限和关闭在请求/分块前后检查,不能瞬时中止正在阻塞的系统调用;请设置有限超时。对象及回调只在创建线程使用,跨线程请传 spec 后重建。

httpRangeSourceObject.etag #

调用方指定的强 ETag(可省略),每次读取发送 If-Match 并检查应答。

httpRangeSourceObject.expiresAt #

可选 Unix 秒截止时间,达到期限即拒绝读取。

httpRangeSourceObject.read(offset,count) #

同步读取恰好 count 字节,偏移从 0 开始;成功返回 buffer,失败返回 null,err。
EOF 的零长度读取返回空字符串且不联网;单次默认最多 16 MiB。校验 206、Content-Range、长度、identity 编码和可选 ETag。请在工作线程调用。

httpRangeSourceObject.representationId #

URL、指定验证器和长度构成的宿主标识,不是内容哈希,可能含私有 URL,不应导出给网页。

httpRangeSourceObject.size #

固定总字节数;不要修改对象元数据。

Markdown 格式