WN home page

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

Ranges on the WN Server

9.1 URL Range Parameters

If the server receives a request like:


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:


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:


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


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.5.0
Copyright © 1998-2005 John Franks <john@math.northwestern.edu>
licensed under the GNU Free Documentation License
Last modified: Sat June 18 2005
[Previous] [Next] [Up] [Top] [Search] [Index]