[HTTP]レンジリクエスト
ヘッダフィールドRangeで指定すると、範囲を指定して一部分だけリクエストを送れます。
telnetで接続して試してみます。
まずは普通にリクエストを送ってみます。
$ telnet localhost 80 Trying ::1... Connected to localhost. Escape character is '^]'. GET /test.html HTTP/1.1 Host: localhost HTTP/1.1 200 OK Date: Sun, 09 Mar 2008 00:51:52 GMT Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 Content-Location: index.html.en Vary: negotiate,accept-language,accept-charset TCN: choice Last-Modified: Sun, 25 Nov 2007 04:49:49 GMT ETag: "ee64-5b0-43fb993dbd540;4460bc0daec40" Accept-Ranges: bytes Content-Length: 1456 Content-Type: text/html Content-Language: en <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Page for Apache Installation</title> </head> <!-- Background white, links blue (unvisited), navy (visited), red (active) --> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#000080" alink="#FF0000"> <p>If you can see this, it means that the installation of the <a href="http://www.apache.org/foundation/preFAQ.html">Apache web server</a> software on this system was successful. You may now add content to this directory and replace this page.</p> <hr width="50%" size="8" /> <h2 align="center">Seeing this instead of the website you expected?</h2> <p>This page is here because the site administrator has changed the configuration of this web server. Please <strong>contact the person responsible for maintaining this server with questions.</strong> The Apache Software Foundation, which wrote the web server software this site administrator is using, has nothing to do with maintaining this site and cannot help resolve configuration issues.</p> </body> </html> Connection closed by foreign host.
次に、範囲を指定してリクエストを送ります。
Range:bytes=201-500で、リソースの201バイトから500バイトのバイトレンジだけリクエストします。
$ telnet localhost 80 Trying ::1... Connected to localhost. Escape character is '^]'. GET /test.html HTTP/1.1 Host: localhost Range:bytes=201-500 HTTP/1.1 206 Partial Content Date: Sun, 09 Mar 2008 01:08:36 GMT Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 Content-Location: index.html.en Vary: negotiate,accept-language,accept-charset TCN: choice Last-Modified: Sun, 25 Nov 2007 04:49:49 GMT ETag: "ee64-5b0-43fb993dbd540;4460bc0daec40" Accept-Ranges: bytes Content-Length: 300 Content-Range: bytes 201-500/1456 Content-Type: text/html Content-Language: en che Installation</title> </head> <!-- Background white, links blue (unvisited), navy (visited), red (active) --> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#000080" alink="#FF0000"> <p>If you can see this, it means that the installation of the <a href="http://www.apache.org/foundatConnection closed by foreign host.
レンジリクエストに対するレスポンスはステータスコード206 Partial Contentが返ります。
また、サーバがレンジリクエストに対応していない場合、ステータスコード200 OK のレスポンスで完全なエンティティが返されます。
Range:で指定する範囲ですが、Range:bytes=201- とすると201バイトより後をすべてを要求し、
Range:bytes=-200, 301-400とすると、200バイトまでと301バイトから400バイトまでの複数の範囲を要求できます。