gpt4 book ai didi

Python3 :requests module headers

转载 作者:行者123 更新时间:2023-12-01 09:09:21 25 4
gpt4 key购买 nike

我正在创建一个可以使用请求模块暂停的下载,并且我正在使用 header Range

如果内容长度为 1000 字节,下载到 500 字节时暂停(即 Range:bytes=0-499)。现在,当它恢复时,范围应该是多少?

这个:

Range:bytes=499-1000

或者这个:

Range:bytes=500-1000

或者这个:

Range:bytes=500-1001

还是其他什么?

提前致谢。

最佳答案

The first-byte-pos value in a byte-range-spec gives the byte-offset of the first byte in a range. The last-byte-pos value gives the byte-offset of the last byte in the range; that is, the byte positions specified are inclusive. Byte offsets start at zero.

If the last-byte-pos value is present, it MUST be greater than or equal to the first-byte-pos in that byte-range-spec, or the byte- range-spec is syntactically invalid. The recipient of a byte-range- set that includes one or more syntactically invalid byte-range-spec values MUST ignore the header field that includes that byte-range- set.

If the last-byte-pos value is absent, or if the value is greater than or equal to the current length of the entity-body, last-byte-pos is taken to be equal to one less than the current length of the entity- body in bytes.

你的答案是:

bytes=500-999 or bytes=500-

更多信息请参见 HTTP protocol RFC

关于Python3 :requests module headers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51796267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com