WN home page

Version 2.0.3
[Previous] [Next] [Up] [Top] [Search] [Index]

Ranges on the WN Server


9.1 URL Range Parameters

If the server receives a request like:

http://host/dir/foo;lines=20-30

and foo is any document with content-type text/* it will return a text/plain document consisting of lines 20 through 30 of file foo. This is very useful for structured text files like address lists or digests of mail and news. A WN utility called wn_mkdigest will produce an HTML file with a list of links to separate sections (line ranges) of the structured file. It is described below.

The option ";lines=[first]-[last]" can be appended to the URL of any text file served by the WN server. It has the effect of causing the server to return line [first] through line [last] of the document to which it is attached. Line 1 is the first line of a file. This parameter is ignored and an error is logged if it is used with a binary file. When used with a text file the content type of the returned document is set to text/plain since, for example, a range of lines from an HTML document is unlikely to be a valid HTML document.

For any file, including binaries, but not CGI/1.1 output or parsed or filtered documents, the server will honor a byte range. A request for:

http://host/dir/foo;bytes=256-1024

will cause the server to return bytes 256 to 1024 inclusive. The first byte is numbered 0 so a range of 0-100 represents the first 101 bytes. Note that while file lines are numbered starting with 1, bytes are numbered starting with 0. The content type of the returned document will be text/plain if the document foo is a text document and application/octet-stream otherwise.

A request for:

http://host/dir/foo;bytes=256-

will cause the server to return bytes 256 through the end of the file, while:

http://host/dir/foo;bytes=-1024

requests the last 1024 bytes of the file.

9.2 The "Range:" Header

Requests for a specific range can also be made with the proposed HTTP/1.1 header "Range:". For example, if the server receives a request with the header:

Range: bytes=100-200

it will send the 101 bytes starting with the 100th and ending with the 200th. The header "Range: bytes=300-" requests all bytes starting with number 300 and continuing until the end of the file. And "Range: bytes=-300" requests the last 300 bytes of the file. This is normally done automatically by the client in appropriate circumstances and is not under the control of the server administrator.

9.3 The wn_mkdigest Utility

The wn_mkdigest utility is executed with two regular expressions: one to match the section separator and the other to match the section title. For example, for a mail digest named foo, the command:

wn_mkdigest foo "^From" "^Subject:" foo

will produce an HTML file called foo.index.html which contains an unordered list of anchors. Each has as a title the content of the Subject line of a mail message in foo and href the range of lines in foo containing that particular message. More detailed information is available in the section "wn_mkdigest" in this guide.


WN version 2.0.3
Copyright © 1998 John Franks <john@math.nwu.edu>
licensed under the OpenContent Public License
last-modified: Fri, 09 Oct 1998 18:18:09 GMT
[Previous] [Next] [Up] [Top] [Search] [Index]