HttpWebRequest.AddRange 方法

定義

將範圍標頭加入至要求。Adds a range header to the request.

多載

AddRange(Int32)

針對從已要求資料的起始或結尾的特定範圍,將位元組範圍標頭加入至要求。Adds a byte range header to a request for a specific range from the beginning or end of the requested data.

AddRange(Int64)

針對從已要求資料的起始或結尾的特定範圍,將位元組範圍標頭加入至要求。Adds a byte range header to a request for a specific range from the beginning or end of the requested data.

AddRange(Int32, Int32)

將範圍標頭加入至特定範圍的要求。Adds a byte range header to the request for a specified range.

AddRange(Int64, Int64)

將範圍標頭加入至特定範圍的要求。Adds a byte range header to the request for a specified range.

AddRange(String, Int32)

針對從已要求資料的起始或結尾的特定範圍,將範圍標頭加入至要求。Adds a Range header to a request for a specific range from the beginning or end of the requested data.

AddRange(String, Int64)

針對從已要求資料的起始或結尾的特定範圍,將範圍標頭加入至要求。Adds a Range header to a request for a specific range from the beginning or end of the requested data.

AddRange(String, Int32, Int32)

將範圍標頭加入至特定範圍的要求。Adds a range header to a request for a specified range.

AddRange(String, Int64, Int64)

將範圍標頭加入至特定範圍的要求。Adds a range header to a request for a specified range.

備註

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

AddRange(Int32)

針對從已要求資料的起始或結尾的特定範圍,將位元組範圍標頭加入至要求。Adds a byte range header to a request for a specific range from the beginning or end of the requested data.

public:
 void AddRange(int range);
public void AddRange (int range);
member this.AddRange : int -> unit
Public Sub AddRange (range As Integer)

參數

range
Int32

範圍的起始和結束點。The starting or ending point of the range.

例外狀況

rangeSpecifier 無效。rangeSpecifier is invalid.

無法加入範圍標頭。The range header could not be added.

範例

下列程式碼範例會將範圍標頭加入至要求。The following code example adds a range header to the request.

// Create a New 'HttpWebRequest' object.
HttpWebRequest^ myHttpWebRequest1 = 
    (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) );
myHttpWebRequest1->AddRange( 1000);
Console::WriteLine("Call AddRange(1000)");
      Console::Write("Resulting Headers: ");
      Console::WriteLine(myHttpWebRequest1->Headers);

HttpWebRequest^ myHttpWebRequest2 = 
    (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) );
myHttpWebRequest2->AddRange(-1000);
Console::WriteLine("Call AddRange(-1000)");
      Console::Write("Resulting Headers: ");
      Console::WriteLine(myHttpWebRequest2->Headers);

// Create a New 'HttpWebRequest' object .
HttpWebRequest myHttpWebRequest1=(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
myHttpWebRequest1.AddRange(1000);	
Console.WriteLine("Call AddRange(1000)");
Console.Write("Resulting Headers: ");
Console.WriteLine(myHttpWebRequest1.Headers.ToString());

// Create a New 'HttpWebRequest' object .
HttpWebRequest myHttpWebRequest2=(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
myHttpWebRequest2.AddRange(-1000);	
Console.WriteLine("Call AddRange(-1000)");
Console.Write("Resulting Headers: ");
Console.WriteLine(myHttpWebRequest2.Headers.ToString());
' A New 'HttpWebRequest' object is created.
Dim myHttpWebRequest1 As HttpWebRequest = WebRequest.Create("http://www.contoso.com")
myHttpWebRequest1.AddRange(1000)
Console.WriteLine("Call AddRange(1000)")
      Console.Write("Resulting Headers: ")
      Console.WriteLine(myHttpWebRequest1.Headers.ToString())

Dim myHttpWebRequest2 As HttpWebRequest = WebRequest.Create("http://www.contoso.com")
myHttpWebRequest2.AddRange(-1000)
Console.WriteLine("Call AddRange(-1000)")
      Console.Write("Resulting Headers: ")
      Console.WriteLine(myHttpWebRequest2.Headers.ToString())

備註

HttpWebRequest.AddRange 方法會將位元組範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a byte range header to the request.

如果 range 是正數,則 range 參數會指定範圍的起始點。If range is positive, the range parameter specifies the starting point of the range. 伺服器應該會開始將資料從指定的 range 參數傳送到 HTTP 實體中的資料結尾。The server should start sending data from the range parameter specified to the end of the data in the HTTP entity.

如果 range 為負數,則 range 參數會指定範圍的結束點。If range is negative, the range parameter specifies the ending point of the range. 伺服器應該會開始從 HTTP 實體中的資料開頭將資料傳送到指定的 range 參數。The server should start sending data from the start of the data in the HTTP entity to the range parameter specified.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

HTTP 通訊協定要求中的範圍標頭範例會要求伺服器傳送前100個位元組(從開始到位元組位置99),如下所示:An example of a Range header in an HTTP protocol request that requests the server send the first 100 bytes (from the start to byte position 99) would be the following:

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

在此範例中,range 參數會是-99。For this example, the range parameter would be -99.

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

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

AddRange(Int64)

針對從已要求資料的起始或結尾的特定範圍,將位元組範圍標頭加入至要求。Adds a byte range header to a request for a specific range from the beginning or end of the requested data.

public:
 void AddRange(long range);
public void AddRange (long range);
member this.AddRange : int64 -> unit
Public Sub AddRange (range As Long)

參數

range
Int64

範圍的起始和結束點。The starting or ending point of the range.

例外狀況

rangeSpecifier 無效。rangeSpecifier is invalid.

無法加入範圍標頭。The range header could not be added.

備註

HttpWebRequest.AddRange 方法會將位元組範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a byte range header to the request.

如果 range 是正數,則 range 參數會指定範圍的起始點。If range is positive, the range parameter specifies the starting point of the range. 伺服器應該會開始將資料從指定的 range 參數傳送到 HTTP 實體中的資料結尾。The server should start sending data from the range parameter specified to the end of the data in the HTTP entity.

如果 range 為負數,則 range 參數會指定範圍的結束點。If range is negative, the range parameter specifies the ending point of the range. 伺服器應該會開始從 HTTP 實體中的資料開頭將資料傳送到指定的 range 參數。The server should start sending data from the start of the data in the HTTP entity to the range parameter specified.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

HTTP 通訊協定要求中的範圍標頭範例會要求伺服器傳送前100個位元組(從開始到位元組位置99),如下所示:An example of a Range header in an HTTP protocol request that requests the server send the first 100 bytes (from the start to byte position 99) would be the following:

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

在此範例中,range 參數會是-99。For this example, the range parameter would be -99.

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

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

AddRange(Int32, Int32)

將範圍標頭加入至特定範圍的要求。Adds a byte range header to the request for a specified range.

public:
 void AddRange(int from, int to);
public void AddRange (int from, int to);
member this.AddRange : int * int -> unit
Public Sub AddRange (from As Integer, to As Integer)

參數

from
Int32

要開始傳送資料的位置。The position at which to start sending data.

to
Int32

要停止傳送資料的位置。The position at which to stop sending data.

例外狀況

rangeSpecifier 無效。rangeSpecifier is invalid.

from 大於 tofrom is greater than to

-或--or- fromto 小於 0。from or to is less than 0.

無法加入範圍標頭。The range header could not be added.

範例

下列程式碼範例會將範圍標頭加入至要求。The following code example adds a range header to the request.

// Create a New 'HttpWebRequest' object.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) );
myHttpWebRequest->AddRange( 50, 150 );
Console::WriteLine("Call AddRange(50, 150)");
      Console::Write("Resulting Request Headers: ");
      Console::WriteLine(myHttpWebRequest->Headers);

// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() );

// Displays the headers in the response received
Console::Write("Resulting Response Headers: ");
      Console::WriteLine(myHttpWebResponse->Headers);

// Display the contents of the page to the console.
Stream^ streamResponse = myHttpWebResponse->GetResponseStream();
StreamReader^ streamRead = gcnew StreamReader( streamResponse );
array<Char>^ readBuffer = gcnew array<Char>(256);
int count = streamRead->Read( readBuffer, 0, 256 );
Console::WriteLine( "\nThe HTML contents of the page from 50th to 150 charaters are :\n  " );
while ( count > 0 )
{
   String^ outputData = gcnew String( readBuffer,0,count );
   Console::WriteLine( outputData );
   count = streamRead->Read( readBuffer, 0, 256 );
}
streamRead->Close();
streamResponse->Close();
myHttpWebResponse->Close();
      // Create a New 'HttpWebRequest' object .
      HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
      myHttpWebRequest.AddRange(50,150);	
      Console.WriteLine("Call AddRange(50,150)");
      Console.Write("Resulting Request Headers: ");
      Console.WriteLine(myHttpWebRequest.Headers.ToString());

      // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
      HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();

// Displays the headers in the response received
Console.Write("Resulting Response Headers: ");
      Console.WriteLine(myHttpWebResponse.Headers.ToString());

      // Display the contents of the page to the console.
      Stream streamResponse=myHttpWebResponse.GetResponseStream();
      StreamReader streamRead = new StreamReader( streamResponse );
      Char[] readBuffer = new Char[256];
      int count = streamRead.Read( readBuffer, 0, 256 );
      Console.WriteLine("\nThe HTML contents of the page from 50th to 150 characters are :\n  ");	
      while (count > 0) 
      {
          String outputData = new String(readBuffer, 0, count);
          Console.WriteLine(outputData);
          count = streamRead.Read(readBuffer, 0, 256);
      }
      // Release the response object resources.
      streamRead.Close();
      streamResponse.Close();
      myHttpWebResponse.Close();
' A New 'HttpWebRequest' objetc is created.
Dim myHttpWebRequest As HttpWebRequest = WebRequest.Create("http://www.contoso.com")
myHttpWebRequest.AddRange(50, 150)
Console.WriteLine("Call AddRange(50, 150)")
      Console.Write("Resulting Request Headers: ")
      Console.WriteLine(myHttpWebRequest.Headers.ToString())

' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

' Displays the headers in the response received
Console.Write("Resulting Response Headers: ")
      Console.WriteLine(myHttpWebResponse.Headers.ToString())

' Displaying the contents of the page to the console
Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
Dim readBuffer(256) As [Char]
Dim count As Integer = streamRead.Read(readBuffer, 0, 256)
Console.WriteLine(ControlChars.Cr + "The HTML contents of the page from 50th to 150 charaters are :" + ControlChars.Cr + "  ")
While count > 0
    Dim outputData As New [String](readBuffer, 0, count)
    Console.WriteLine(outputData)
    count = streamRead.Read(readBuffer, 0, 256)
End While
' Release the response object resources.
 streamRead.Close()
 streamResponse.Close()
myHttpWebResponse.Close()

備註

HttpWebRequest.AddRange 方法會將位元組範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a byte range header to the request.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

HTTP 通訊協定要求中的範圍標頭範例會要求前100個位元組,如下所示: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

在此範例中,from 參數會指定為0,且 to 參數會指定為99。For this example, the from parameter would be specified as 0 and the to parameter would be specified as 99. 範圍規範會由這個方法自動設定為 "bytes"。The range specifier is automatically set as "bytes" by this method.

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

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

AddRange(Int64, Int64)

將範圍標頭加入至特定範圍的要求。Adds a byte range header to the request for a specified range.

public:
 void AddRange(long from, long to);
public void AddRange (long from, long to);
member this.AddRange : int64 * int64 -> unit
Public Sub AddRange (from As Long, to As Long)

參數

from
Int64

要開始傳送資料的位置。The position at which to start sending data.

to
Int64

要停止傳送資料的位置。The position at which to stop sending data.

例外狀況

rangeSpecifier 無效。rangeSpecifier is invalid.

from 大於 tofrom is greater than to

-或--or- fromto 小於 0。from or to is less than 0.

無法加入範圍標頭。The range header could not be added.

備註

HttpWebRequest.AddRange 方法會將位元組範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a byte range header to the request.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

HTTP 通訊協定要求中的範圍標頭範例會要求前100個位元組,如下所示: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

在此範例中,from 參數會指定為0,且 to 參數會指定為99。For this example, the from parameter would be specified as 0 and the to parameter would be specified as 99. 範圍規範會由這個方法自動設定為 "bytes"。The range specifier is automatically set as "bytes" by this method.

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

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

AddRange(String, Int32)

針對從已要求資料的起始或結尾的特定範圍,將範圍標頭加入至要求。Adds a Range header to a request for a specific range from the beginning or end of the requested data.

public:
 void AddRange(System::String ^ rangeSpecifier, int range);
public void AddRange (string rangeSpecifier, int range);
member this.AddRange : string * int -> unit
Public Sub AddRange (rangeSpecifier As String, range As Integer)

參數

rangeSpecifier
String

範圍的描述。The description of the range.

range
Int32

範圍的起始和結束點。The starting or ending point of the range.

例外狀況

rangeSpecifiernullrangeSpecifier is null.

rangeSpecifier 無效。rangeSpecifier is invalid.

無法加入範圍標頭。The range header could not be added.

備註

HttpWebRequest.AddRange 方法會將範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a Range header to the request.

如果 range 是正數,則 range 參數會指定範圍的起始點。If range is positive, the range parameter specifies the starting point of the range. 伺服器應該會開始將資料從指定的 range 參數傳送到 HTTP 實體中的資料結尾。The server should start sending data from the range parameter specified to the end of the data in the HTTP entity.

如果 range 為負數,則 range 參數會指定範圍的結束點。If range is negative, the range parameter specifies the ending point of the range. 伺服器應該會開始從 HTTP 實體中的資料開頭將資料傳送到指定的 range 參數。The server should start sending data from the start of the data in the HTTP entity to the range parameter specified.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

rangeSpecifier 參數通常會指定為「位元組」,因為這是大多數 HTTP 伺服器都能辨識的唯一範圍規範。The rangeSpecifier parameter would normally be specified as a "bytes", since this is the only range specifier recognized by most HTTP servers. rangeSpecifier 參數設定為其他字串,則允許支援位元組以外的自訂範圍規範(由 IETF 定義于 RFC 2616 中的位元組範圍指定名稱)。Setting the rangeSpecifier parameter to some other string allows support for custom range specifiers other than bytes (the byte-range specifier defined in RFC 2616 by the IETF).

HTTP 通訊協定要求中的範圍標頭範例會要求前100個位元組,如下所示: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=-99\r\n\r\n

在此範例中,rangeSpecifier 參數會指定為 "bytes",而 range 參數會是-99。For this example, the rangeSpecifier parameter would be specified as "bytes" and the range parameter would be -99.

HTTP 伺服器表示回應中的範圍標頭支援與接受範圍標頭。A HTTP server indicates support for Range headers with the Accept-Ranges header in the response. 支援位元組範圍之伺服器的接受範圍標頭範例如下所示: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

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

AddRange(String, Int64)

針對從已要求資料的起始或結尾的特定範圍,將範圍標頭加入至要求。Adds a Range header to a request for a specific range from the beginning or end of the requested data.

public:
 void AddRange(System::String ^ rangeSpecifier, long range);
public void AddRange (string rangeSpecifier, long range);
member this.AddRange : string * int64 -> unit
Public Sub AddRange (rangeSpecifier As String, range As Long)

參數

rangeSpecifier
String

範圍的描述。The description of the range.

range
Int64

範圍的起始和結束點。The starting or ending point of the range.

例外狀況

rangeSpecifiernullrangeSpecifier is null.

rangeSpecifier 無效。rangeSpecifier is invalid.

無法加入範圍標頭。The range header could not be added.

備註

HttpWebRequest.AddRange 方法會將範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a Range header to the request.

如果 range 是正數,則 range 參數會指定範圍的起始點。If range is positive, the range parameter specifies the starting point of the range. 伺服器應該會開始將資料從指定的 range 參數傳送到 HTTP 實體中的資料結尾。The server should start sending data from the range parameter specified to the end of the data in the HTTP entity.

如果 range 為負數,則 range 參數會指定範圍的結束點。If range is negative, the range parameter specifies the ending point of the range. 伺服器應該會開始從 HTTP 實體中的資料開頭將資料傳送到指定的 range 參數。The server should start sending data from the start of the data in the HTTP entity to the range parameter specified.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

rangeSpecifier 參數通常會指定為「位元組」,因為這是大多數 HTTP 伺服器都能辨識的唯一範圍規範。The rangeSpecifier parameter would normally be specified as a "bytes", since this is the only range specifier recognized by most HTTP servers. rangeSpecifier 參數設定為其他字串,則允許支援位元組以外的自訂範圍規範(由 IETF 定義于 RFC 2616 中的位元組範圍指定名稱)。Setting the rangeSpecifier parameter to some other string allows support for custom range specifiers other than bytes (the byte-range specifier defined in RFC 2616 by the IETF).

HTTP 通訊協定要求中的範圍標頭範例會要求前100個位元組,如下所示: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=-99\r\n\r\n

在此範例中,rangeSpecifier 參數會指定為 "bytes",而 range 參數會是-99。For this example, the rangeSpecifier parameter would be specified as "bytes" and the range parameter would be -99.

HTTP 伺服器表示回應中的範圍標頭支援與接受範圍標頭。A HTTP server indicates support for Range headers with the Accept-Ranges header in the response. 支援位元組範圍之伺服器的接受範圍標頭範例如下所示: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

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

AddRange(String, Int32, Int32)

將範圍標頭加入至特定範圍的要求。Adds a range header to a request for a specified range.

public:
 void AddRange(System::String ^ rangeSpecifier, int from, int to);
public void AddRange (string rangeSpecifier, int from, int to);
member this.AddRange : string * int * int -> unit
Public Sub AddRange (rangeSpecifier As String, from As Integer, to As Integer)

參數

rangeSpecifier
String

範圍的描述。The description of the range.

from
Int32

要開始傳送資料的位置。The position at which to start sending data.

to
Int32

要停止傳送資料的位置。The position at which to stop sending data.

例外狀況

rangeSpecifiernullrangeSpecifier is null.

from 大於 tofrom is greater than to

-或--or- fromto 小於 0。from or to is less than 0.

rangeSpecifier 無效。rangeSpecifier is invalid.

無法加入範圍標頭。The range header could not be added.

備註

HttpWebRequest.AddRange 方法會將範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a Range header to the request.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

rangeSpecifier 參數通常會指定為「位元組」,因為這是大多數 HTTP 伺服器都能辨識的唯一範圍規範。The rangeSpecifier parameter would normally be specified as a "bytes", since this is the only range specifier recognized by most HTTP servers. rangeSpecifier 參數設定為其他字串,則允許支援位元組以外的自訂範圍規範(由 IETF 定義于 RFC 2616 中的位元組範圍指定名稱)。Setting the rangeSpecifier parameter to some other string allows support for custom range specifiers other than bytes (the byte-range specifier defined in RFC 2616 by the IETF).

HTTP 通訊協定要求中的範圍標頭範例會要求前100個位元組,如下所示: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

在此範例中,rangeSpecifier 參數會指定為 "bytes",from 參數會是0,而 to 參數會是99。For this example, the rangeSpecifier parameter would be specified as a "bytes", the from parameter would be 0, and the to parameter would be 99.

HTTP 伺服器表示回應中的範圍標頭支援與接受範圍標頭。A HTTP server indicates support for Range headers with the Accept-Ranges header in the response. 支援位元組範圍之伺服器的接受範圍標頭範例如下所示: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

在接受範圍標頭中指定的字串是範圍規範,會在這個方法的 rangeSpecifier 參數中指定。The string specified in the Accept-Ranges header is the range-specifier that would be by specified in the rangeSpecifier parameter for this method.

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

AddRange(String, Int64, Int64)

將範圍標頭加入至特定範圍的要求。Adds a range header to a request for a specified range.

public:
 void AddRange(System::String ^ rangeSpecifier, long from, long to);
public void AddRange (string rangeSpecifier, long from, long to);
member this.AddRange : string * int64 * int64 -> unit
Public Sub AddRange (rangeSpecifier As String, from As Long, to As Long)

參數

rangeSpecifier
String

範圍的描述。The description of the range.

from
Int64

要開始傳送資料的位置。The position at which to start sending data.

to
Int64

要停止傳送資料的位置。The position at which to stop sending data.

例外狀況

rangeSpecifiernullrangeSpecifier is null.

from 大於 tofrom is greater than to

-或--or- fromto 小於 0。from or to is less than 0.

rangeSpecifier 無效。rangeSpecifier is invalid.

無法加入範圍標頭。The range header could not be added.

備註

HttpWebRequest.AddRange 方法會將範圍標頭加入至要求。The HttpWebRequest.AddRange method adds a Range header to the request.

由於所有 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.

要求的範圍標頭可讓用戶端要求它只想要接收 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.

rangeSpecifier 參數通常會指定為「位元組」,因為這是大多數 HTTP 伺服器都能辨識的唯一範圍規範。The rangeSpecifier parameter would normally be specified as a "bytes", since this is the only range specifier recognized by most HTTP servers. rangeSpecifier 參數設定為其他字串,則允許支援位元組以外的自訂範圍規範(由 IETF 定義于 RFC 2616 中的位元組範圍指定名稱)。Setting the rangeSpecifier parameter to some other string allows support for custom range specifiers other than bytes (the byte-range specifier defined in RFC 2616 by the IETF).

HTTP 通訊協定要求中的範圍標頭範例會要求前100個位元組,如下所示: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

在此範例中,rangeSpecifier 參數會指定為 "bytes",from 參數會是0,而 to 參數會是99。For this example, the rangeSpecifier parameter would be specified as a "bytes", the from parameter would be 0, and the to parameter would be 99.

HTTP 伺服器表示回應中的範圍標頭支援與接受範圍標頭。A HTTP server indicates support for Range headers with the Accept-Ranges header in the response. 支援位元組範圍之伺服器的接受範圍標頭範例如下所示: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

在接受範圍標頭中指定的字串是範圍規範,會在這個方法的 rangeSpecifier 參數中指定。The string specified in the Accept-Ranges header is the range-specifier that would be by specified in the rangeSpecifier parameter for this method.

如果未在伺服器回應的標頭中收到接受範圍標頭,則伺服器不支援範圍標頭。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. 伺服器的接受範圍標頭範例不支援範圍,但可辨識接受範圍標頭,如下所示: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

接收範圍要求的回應時,只會剖析與整個要求相關聯的 HTTP 標頭,並可透過 HttpWebResponse 類別的屬性來取得。When receiving the response from a range request, only the HTTP headers associated with the entire request are parsed and made available via properties on the HttpWebResponse class. 回應中會傳回與每個範圍相關聯的標頭。Headers associated with each range are returned in the response.

另請參閱

適用於