RangeHeaderValue 类


表示 Range 标头值。Represents a Range header value.

public ref class RangeHeaderValue : ICloneable
public class RangeHeaderValue : ICloneable
type RangeHeaderValue = class
    interface ICloneable
Public Class RangeHeaderValue
Implements ICloneable


RangeHeaderValue 类支持由 IETF 在RFC 2616中定义的范围标头。The RangeHeaderValue class provides support for the Range header as defined in RFC 2616 by the IETF.

由于所有 HTTP 实体都在 HTTP 消息中表示为字节序列,因此字节范围的概念对于任何 HTTP 实体都是有意义的。Since all HTTP entities are represented in HTTP messages as sequences of bytes, the concept of a byte range is meaningful for any HTTP entity. 但是,并不是所有的客户端和服务器都需要支持字节范围的操作。However, not all clients and servers need to support byte-range operations.

请求上的 Range 标头允许客户端请求仅接收 HTTP 实体中指定范围内的某个部分。The Range header on a request allows a client to request that it only wants to receive some part of the specified range of bytes in an HTTP entity. 服务器不需要支持范围标头请求。Servers are not required to support Range header requests.

请求前100个字节的 HTTP 协议请求中的范围标头示例如下:An example of a Range header in an HTTP protocol request that requests the first 100 bytes would be would be the following:

Range: bytes=0-99\r\n\r\n

HTTP 服务器指示支持范围标头和接受范围标头。A HTTP server indicates support for Range headers with the Accept-Ranges header. 支持字节范围的服务器的接受范围标头示例如下所示:An example of the Accept-Ranges header from a server that supports byte-ranges would be as follows:

Accept-Ranges: bytes\r\n\r\n

如果服务器的响应标头中未收到 Accept 范围的标头,则服务器不支持范围标头。If an Accept-Ranges header is not received in the header of the response from the server, then the server does not support Range headers. 不支持范围但可识别接受范围标头的服务器的 Accept 范围标头的示例如下所示:An example of the Accept-Ranges header from a server that does not support ranges, but recognizes the Accept-Ranges header, would be as follows:

Accept-Ranges: none\r\n\r\n



初始化 RangeHeaderValue 类的新实例。Initializes a new instance of the RangeHeaderValue class.

RangeHeaderValue(Nullable<Int64>, Nullable<Int64>)

使用字节范围初始化 RangeHeaderValue 类的新实例。Initializes a new instance of the RangeHeaderValue class with a byte range.



获取从 RangeHeaderValue 对象指定的范围。Gets the ranges specified from the RangeHeaderValue object.


获取 RangeHeaderValue 对象的单位。Gets the unit from the RangeHeaderValue object.



确定指定的 Object 是否等于当前的 RangeHeaderValue 对象。Determines whether the specified Object is equal to the current RangeHeaderValue object.


充当 RangeHeaderValue 对象的哈希函数。Serves as a hash function for an RangeHeaderValue object.


获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)

将字符串转换为 RangeHeaderValue 实例。Converts a string to an RangeHeaderValue instance.


返回表示当前 RangeHeaderValue 对象的字符串。Returns a string that represents the current RangeHeaderValue object.

TryParse(String, RangeHeaderValue)

确定一个字符串是否为有效的 RangeHeaderValue 信息。Determines whether a string is valid RangeHeaderValue information.



创建作为当前 RangeHeaderValue 实例副本的新对象。Creates a new object that is a copy of the current RangeHeaderValue instance.