Article View: news.software.nntp
Article #66849New NNTP draft -- Sections 1-3
From: Russ Allbery
Date: Sat, 18 Oct 2003 04:37
Date: Sat, 18 Oct 2003 04:37
609 lines
30373 bytes
30373 bytes
[ See <http://www.davros.org/nntp-texts/draft20.txt> for the complete
document, including credits and references. This is the first in a
series of postings of the sections of the new NNTP draft, which is
currently in Last Call. ]
NNTP C. Feather
Internet-Draft Thus plc
Expires: April 15, 2004 October 16, 2003
1. Introduction
This document specifies the Network News Transport Protocol (NNTP),
which is used for the distribution, inquiry, retrieval, and posting
of Netnews articles using a reliable stream-based mechanism. For news
reading clients, NNTP enables retrieval of news articles that are
stored in a central database, giving subscribers the ability to
select only those articles they wish to read.
The Netnews model provides for indexing, cross-referencing, and
expiration of aged messages. For server-to-server interaction, NNTP
is designed for efficient transmission of Netnews articles over a
reliable full duplex communication channel.
Every attempt is made to ensure that the protocol specification in
this document is compatible with the version specified in RFC 977
[RFC977]. However, this version does not support the ill-defined
SLAVE command and permits four digit years to be specified in the
NEWNEWS and NEWGROUPS commands. It changes the default character set
to UTF-8 [RFC2279] instead of US-ASCII [ANSI1986]. It now requires
all articles to have a message-id, eliminating the "<0>" placeholder
used in RFC 977. It also extends the newsgroup name matching
capabilities already documented in RFC 977.
Generally, new functionality is made available using new commands. A
number of such commands (including some commands taken from RFC 2980
[RFC2980]) are now mandatory. Part of the new functionality involves
a mechanism to discover what new functionality is available to
clients from a server. This mechanism can also be used to add more
functionality as needs merit such additions.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 [RFC2119].
An implementation is not compliant if it fails to satisfy one or more
of the MUST requirements for this protocol. An implementation that
satisfies all the MUST and all the SHOULD requirements for its
protocols is said to be "unconditionally compliant"; one that
satisfies all the MUST requirements but not all the SHOULD
requirements for NNTP is said to be "conditionally compliant".
For the remainder of this document, the term "client" or "client
host" refers to a host making use of the NNTP service, while the term
"server" or "server host" refers to a host that offers the NNTP
service.
2. Notation
The following notational conventions are used in this document.
UPPERCASE indicates literal text to be included in the
command;
lowercase indicates a token described elsewhere;
[brackets] indicate that the argument is optional;
ellipsis... indicates that the argument may be repeated any
number of times (it must occur at least once);
vertical|bar indicates a choice of two mutually exclusive
arguments (exactly one must be provided).
The name "message-id" for a command or response argument indicates
that it is the message-id of an article as described in Section 3.4,
including the angle brackets.
The name "wildmat" for a argument indicates that it is a wildmat as
defined in Section 4. If the argument does not meet the requirements
of that section (for example, if it does not fit the grammar of
Section 4.1) the NNTP server MAY place some interpretation on it (not
specified by this document) or otherwise MUST treat it as a syntax
error.
Responses for each command will be described in tables listing the
required format of a response followed by the meaning that should be
ascribed to that response.
The terms "NUL", "TAB", "LF", "CR, and "space" refer to the octets
with those codes in US-ASCII [ANSI1986] (that is, %x00, %x09, %x0A,
%x0D, and %x20 respectively), as do quoted characters (so "." and "<"
refer to %x2E and %x3C). The term "CRLF" or "CRLF pair" means the
sequence CR immediately followed by LF (that is, %x0D.0A). A
"printable US-ASCII character" is an octet in the range %x21-7E.
Examples in this document are not normative but serve to illustrate
usages, arguments, and responses. In the examples, a "[C]" will be
used to represent the client host and a "[S]" will be used to
represent the server host. Most of the examples do not rely on a
particular server state. In some cases, however, they do assume that
the current selected newsgroup (see the GROUP command (Section
6.1.1)) is invalid; when so, this is indicated at the start of the
example.
Terms which might be read as specifying details of a client or server
implementation, such as "database", are used simply to ease
description. Providing that implementations conform to the protocol
and format specifications in this document, no specific technique is
mandated.
3. Basic Concepts
3.1 Commands and Responses
NNTP operates over any reliable data stream 8-bit-wide channel.
Initially, the server host starts the NNTP service by listening on a
TCP port; when running over TCP/IP, the official port for the NNTP
service is 119. When a client host wishes to make use of the service,
it MUST establish a TCP connection with the server host by connecting
to that host on the same port on which the server is listening. When
the connection is established, the NNTP server host MUST send a
greeting. The client host and server host then exchange commands and
responses (respectively) until the connection is closed or aborted.
The character set for all NNTP commands is UTF-8 [RFC2279]. Commands
in NNTP MUST consist of a keyword, which MAY be followed by one or
more arguments. A CRLF pair MUST terminate all commands. Multiple
commands MUST NOT be on the same line. Keywords MUST consist of
printable US-ASCII characters. Unless otherwise noted elsewhere in
this document, arguments SHOULD consist of printable US-ASCII
characters. Keywords and arguments MUST be each separated by one or
more space or TAB characters. Keywords MUST be at least three
characters and MUST NOT exceed 12 characters. Command lines MUST NOT
exceed 512 octets, which includes the terminating CRLF pair. The
arguments MUST NOT exceed 497 octets. A server MAY relax these limits
for commands defined in an extension.
Where this specification permits UTF-8 characters outside the range
U+0000 to U+007F, implementations MUST NOT use the Byte Order Mark
(U+FEFF, encoding %xEF.BB.BF), and MUST use the Word Joiner (U+2060,
encoding %xE2.91.A0) for the meaning Zero Width No-Break Space, in
command lines and the initial lines of responses, and SHOULD apply
these same principles throughout.
Commands may have variants, using a second keyword immediately after
the first to indicate which variant is required. The only such
commands in this specification are LIST and MODE. Note that such
variants are sometimes referred to as if they were commands in their
own right: "the LIST ACTIVE" command should be read as shorthand for
"the ACTIVE variant of the LIST command".
Keywords are case-insensitive; the case of keywords for commands MUST
be ignored by the server. Command and response arguments are case or
language specific only when stated, either in this document or in
other relevant specifications.
An NNTP server MUST implement all the commands in this specification
except for those marked as optional and those in extensions.
Each response MUST start with a three-digit response code that is
sufficient to distinguish all responses. Certain valid responses are
defined to be multi-line; for all others, the response is contained
in a single line. The first or only line of the response MUST NOT
exceed 512 octets, which includes the response code and the
terminating CRLF pair; an extension MAY specify a greater maximum for
commands that it defines, but not for any other command.
All multi-line responses MUST adhere to the following format:
1. The response consists of a sequence of one or more "lines", each
being a stream of octets ending with a CRLF pair. Apart from
those line endings, the stream MUST NOT include the octets NUL,
LF, or CR.
2. The first such line contains the response code as with a single
line response.
3. If any subsequent line begins with the "termination octet" ("."
or %x2E), that line MUST be "byte-stuffed" by pre-pending an
additional termination octet to that line of the response.
4. The lines of the response MUST be followed by a terminating line
consisting of a single termination octet followed by a CRLF pair
in the normal way. Thus a multi-line response is always
terminated with the five octets CRLF "." CRLF (%x0D.0A.2E.0D.0A).
5. When interpreting a multi-line response, the "byte stuffing" MUST
be undone; i.e. the client MUST ensure that, in any line
beginning with the termination octet followed by octets other
than a CRLF pair, that initial termination octet is disregarded.
6. Likewise, the terminating line ("." CRLF or %x2E.0D.0A) MUST NOT
be considered part of the multi-line response; i.e. the client
MUST ensure that any line beginning with the termination octet
followed immediately by a CRLF pair is disregarded; (the first
CRLF pair of the terminating CRLF "." CRLF is, of course, part of
the last line of the response).
Note that texts using an encoding (such as UTF-16 or UTF-32) that may
contain the octets NUL, LF, or CR other than a CRLF pair cannot be
reliably conveyed in the above format. However, except when stated
otherwise, this specification does not require the content to be
UTF-8 and it is possible for octets above and below 128 to be mixed
arbitrarily.
This document does not place any limit on the length of a subsequent
line in a multi-line response. However, the standards that define the
format of articles may do so.
An NNTP server MAY have an inactivity autologout timer. Such a timer
SHOULD be of at least three minutes duration, with the exception that
there MAY be a shorter limit on how long the server is willing to
wait for the first command from the client. The receipt of any
command from the client during the timer interval SHOULD suffice to
reset the autologout timer. Similarly, the receipt of any significant
amount of data from the client while in the midst of sending a
multi-line message to the server (such as during a POST or IHAVE
command) SHOULD suffice to reset the autologout timer. When the timer
expires, the server SHOULD close the TCP connection without sending
any response to the client.
3.2 Response Codes
Each response MUST begin with a three-digit status indicator. These
are status reports from the server and indicate the response to the
last command received from the client.
The first digit of the response broadly indicates the success,
failure, or progress of the previous command:
1xx - Informative message.
2xx - Command completed OK.
3xx - Command OK so far; send the rest of it.
4xx - Command was syntactically correct but failed for some
reason.
5xx - Command unknown, unsupported, unavailable, or syntax error.
The next digit in the code indicates the function response category:
x0x - Connection, setup, and miscellaneous messages
x1x - Newsgroup selection
x2x - Article selection
x3x - Distribution functions
x4x - Posting
x8x - Reserved for authentication and privacy extensions
x9x - Reserved for private use (non-standard extensions)
Certain responses contain arguments such as numbers and names in
addition to the status indicator. In those cases, to simplify
interpretation by the client the number and type of such arguments is
fixed for each response code, as is whether or not the code
introduces a multi-line response. Any extension MUST follow this
principle as well, but note that, for historical reasons, the 211
response code is an exception to this. In all other cases, the client
MUST only use the status indicator itself to determine the nature of
the response. The exact response codes that can be returned by any
given command are detailed in the description of that command.
Arguments MUST be separated from the numeric status indicator and
from each other by a single space. All numeric arguments MUST be in
base 10 (decimal) format, and MAY have leading zeros. String
arguments MUST contain at least one character and MUST NOT contain
TAB, LF, CR, or space. The server MAY add any text after the response
code or last argument as appropriate, and the client MUST NOT make
decisions based on this text. Such text MUST be separated from the
numeric status indicator or the last argument by at least one space.
The server MUST respond to any command with the appropriate generic
response (given in Section 3.2.1) if it represents the situation.
Otherwise, each recognized command MUST return one of the response
codes specifically listed in its description or in an extension. A
server MAY provide extensions to this specification, including new
commands, new variants or features of existing commands, and other
ways of changing the internal state of the server. However, the
server MUST NOT produce any other responses to a client that does not
invoke any of the additional features. (Therefore a client that
restricts itself to this specification will only receive the
responses that are listed.)
If a client receives an unexpected response, it SHOULD use the first
digit of the response to determine the result. For example, an
unexpected 2xx should be taken as success and an unexpected 4xx or
5xx as failure.
Response codes not specified in this document MAY be used for any
installation-specific additional commands also not specified. These
SHOULD be chosen to fit the pattern of x9x specified above.
Neither this document nor any extension registered with IANA (see
Section 8) will specify any response codes of the x9x pattern.
(Implementers of extensions are accordingly cautioned not to use such
responses for extensions that may subsequently be submitted for
registration.)
3.2.1 Generic Response Codes
The server MUST respond to any command with the appropriate one of
the following generic responses if it represents the situation.
If the command is not recognized, or it is an optional command or
extension that is not implemented by the server, the response code
500 MUST be returned.
If there is a syntax error in the arguments of a recognized command,
including the case where more arguments are provided than the command
specifies or the command line is longer than the server accepts, the
response code 501 MUST be returned. The line MUST NOT be truncated or
split and then interpreted. Note that where a command has variants
depending on a second keyword (e.g. LIST ACTIVE and LIST NEWSGROUPS),
then 501 MUST be used when the base command is implemented but the
requested variant is not, and 500 MUST be used only when the base
command itself is not implemented.
If the server experiences an internal fault or problem that means it
is unable to carry out the command (for example, a necessary file is
missing or a necessary service could not be contacted), the response
code 403 MUST be returned. If the server recognises the command but
does not provide an optional feature (for example because it does not
store the required information), or only handles a subset of
legitimate cases (see the HDR command (Section 8.6.1) for an
example), the response code 503 MUST be returned. Note that where a
command is optional (e.g. LIST ACTIVE.TIMES) and is not provided by a
server, this MAY be treated as an unimplemented command (response
code 500 or 501 as appropriate) or as a working command where the
information is not available (response code 503).
If the client is not authorized to use the specified facility when
the server is in its current state, then the appropriate one of the
following response codes MUST be used.
502: it is necessary to terminate the connection and start a new one
with the appropriate authority before the command can be used.
Note that the server MUST NOT close the TCP connection immediately
after a 502 response except at the initial connection (Section
5.1) and with the MODE READER (Section 5.2) command. See also the
latter command for historical usage of this response.
480: the client must authenticate itself to the server (that is,
provide information as to the identity of the client) before the
facility can be used. This will involve the use of an
authentication extension.
483: the client must negotiate appropriate privacy protection on the
connection. This will involve the use of a privacy extension.
401: the client must change the state of the connection in some other
manner. The first argument of the response MUST be the
extension-label (see Section 8) of the extension (which may be a
private extension) that provides the necessary mechanism, or
"MODE-READER" if it is necessary to use the MODE READER (Section
5.2) command.
If the server has to terminate the connection for some reason, it
MUST give a 400 response code to the next command and then
immediately close the TCP connection.
The client MUST be prepared to receive any of these responses for any
command (except, of course, that the server MUST NOT generate a 500
response code for mandatory commands).
3.2.1.1 Examples
Example of an unknown command:
[C] MAIL
[S] 500 Unknown command
Example of an unsupported extension:
[C] LIST EXTENSIONS
[S] 202 Extensions supported:
[S] LISTGROUP
[S] .
[C] OVER
[S] 500 Unknown command
Example of an unsupported variant:
[C] MODE POSTER
[S] 501 Unknown MODE option
Example of a syntax error:
[C] ARTICLE a.message.id@no.angle.brackets
[S] 501 Syntax error
Example of an overlong command line:
[C] HEAD 53 54 55
[S] 501 Too many arguments
Example of a bad wildmat:
[C] LIST ACTIVE u[ks].*
[S] 501 Syntax error
Example of an attempt to access a facility not available to this
connection:
[C] MODE READER
[S] 200 Reader mode, posting permitted
[C] IHAVE <i.am.an.article.you.will.want@example.com>
[S] 502 Permission denied
Example of an attempt to access a facility requiring authentication:
[C] GROUP secret.group
[S] 480 Permission denied
followed by a successful attempt following such authentication:
[C] XSECRET fred flintstone
[S] 290 Password for fred accepted
[C] GROUP secret.group
[S] 211 5 1 20 secret.group selected
Example of an attempt to access a facility requiring privacy:
[C] GROUP secret.group
[S] 483 Secure connection required
[C] XENCRYPT
[Client and server negotiate encryption on the link]
[S] 283 Encrypted link established
[C] GROUP secret.group
[S] 211 5 1 20 secret.group selected
Example of a need to change mode before using a facility:
[C] GROUP binary.group
[S] 401 XHOST Not on this virtual host
[C] XHOST binary.news.example.org
[S] 290 binary.news.example.org virtual host selected
[C] GROUP binary.group
[S] 211 5 1 77 binary.group selected
Example of a temporary failure:
[C] GROUP archive.local
[S] 403 Archive server temporarily offline
Example of the server needing to close down immediately:
[C] ARTICLE 123
[S] 400 Power supply failed, running on UPS
[Server closes connection.]
3.3 Pipelining
NNTP is designed to operate over a reliable bi-directional connection
such as TCP. Therefore, if a command does not depend on the response
to the previous one, it should not matter if it is sent before that
response is received. Doing this is called "pipelining". However,
certain server implementations throw away all text received from the
client following certain commands before sending their response. If
this happens, pipelining will be affected because one or more
commands will have been ignored or misinterpreted, and the client
will be matching the wrong responses to each command. Since there are
significant benefits to pipelining, but also circumstances where it
is reasonable or common for servers to behave in the above manner,
this document puts certain requirements on both clients and servers.
Except where stated otherwise, a client MAY use pipelining. That is,
it may send a command before receiving the response for the previous
command. The server MUST allow pipelining and MUST NOT throw away any
text received after a command. Irrespective of whether or not
pipelining is used, the server MUST process commands in the order
they are sent.
If the specific description of a command says it "MUST NOT be
pipelined", that command MUST end any pipeline of commands. That is,
the client MUST NOT send any following command until receiving the
CRLF at the end of the response from the command. The server MAY
ignore any data received after the command and before the CRLF at the
end of the response is sent to the client.
The initial connection must not be part of a pipeline; that is, the
client MUST NOT send any command until receiving the CRLF at the end
of the greeting.
If the client uses blocking system calls to send commands, it MUST
ensure that the amount of text sent in pipelining does not cause a
deadlock between transmission and reception. The amount of text
involved will depend on window sizes in the transmission layer, and
is typically 4k octets for TCP.
3.3.1 Examples
Example of correct use of pipelining:
[C] GROUP misc.test
[C] STAT
[C] NEXT
[S] 211 1234 3000234 3002322 misc.test
[S] 223 3000234 <45223423@example.com> retrieved
[S] 223 3000237 <668929@example.org> retrieved
Example of incorrect use of pipelining (the MODE READER command may
not be pipelined):
[C] GROUP misc.test
[C] MODE READER
[C] DATE
[C] NEXT
[S] 211 1234 3000234 3002322 misc.test
[S] 200 Server ready, posting allowed
[S] 223 3000237 <668929@example.org> retrieved
The DATE command has been thrown away by the server and so there is
no 111 response to match it.
3.4 Articles
NNTP is intended to transfer articles between clients and servers.
For the purposes of this specification, articles are required to
conform to the rules in this section and clients and servers MUST
correctly process any article received from the other that does so.
Note that this requirement applies only to the contents of
communications over NNTP; it does not prevent the client or server
from subsequently rejecting an article for reasons of local policy.
Also see Appendix B for further restrictions on the format of
articles in some uses of NNTP.
An article consists of two parts: the headers and the body. They are
separated by a single empty line, or in other words by two
consecutive CRLF pairs (if there is more than one empty line, the
second and subsequent ones are part of the body). In order to meet
the general requirements of NNTP, an article MUST NOT include the
octet NUL, MUST NOT contain the octets LF and CR other than as part
of a CRLF pair, and MUST end with a CRLF pair. This specification
puts no further restrictions on the body; in particular, it MAY be
empty.
The headers of an article consist of one or more header lines. Each
header line consists of a header name, a colon, a space, the header
content, and a CRLF in that order. The name consists of one or more
printable US-ASCII characters other than colon and, for the purposes
of this specification, is not case sensitive. There MAY be more than
one header line with the same name. The content MUST NOT contain CRLF
but is otherwise unrestricted; in particular, it MAY be empty. A
header may be "folded"; that is, a CRLF pair may be placed before any
TAB or space in the line; there MUST still be some other octet
between any two CRLF pairs in a header line. (Note that folding means
that the header line occupies more than one line when displayed or
transmitted; nevertheless it is still referred to as "a" header
line.) The presence or absence of folding does not affect the meaning
of the header line; that is, the CRLF pairs introduced by folding are
not considered part of the header value. Header lines SHOULD NOT be
folded before the space after the colon that follows the header name,
and should include at least one octet other than %x09 or %x20 between
CRLF pairs. However, if an article has been received from elsewhere
with one of these, clients and servers MAY transfer it to the other
without re-folding it.
Each article MUST have a unique message-id; two articles offered by
an NNTP server MUST NOT have the same message-id. For the purposes of
this specification, message-ids are opaque strings that MUST meet the
following requirements:
o A message-id MUST begin with "<" and end with ">", and MUST NOT
contain the latter except at the end.
o A message-id MUST be between 3 and 250 octets in length.
o A message-id MUST NOT contain octets other than printable US-ASCII
characters.
Two message-ids are the same if and only if they consist of the same
sequence of octets.
This specification does not describe how the message-id of an article
is determined. If the server does not have any way to determine a
message-id from the article itself, it MUST synthesise one (this
specification does not require the article to be changed as a
result).
Full Copyright Statement
Copyright (C) The Internet Society (2003). All Rights Reserved.
This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any
kind, provided that the above copyright notice and this paragraph are
included on all such copies and derivative works. However, this
document itself may not be modified in any way, such as by removing
the copyright notice or references to the Internet Society or other
Internet organizations, except as needed for the purpose of
developing Internet standards in which case the procedures for
copyrights defined in the Internet Standards process must be
followed, or as required to translate it into languages other than
English.
The limited permissions granted above are perpetual and will not be
revoked by the Internet Society or its successors or assignees.
This document and the information contained herein is provided on an
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
Please post questions rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Technical Details
Message-ID:
<87fzhryxdc.fsf@windlord.stanford.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!text1.nnrp.aus1!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!199.184.165.233!feed2.news.rcn.net!rcn!logbridge.uoregon.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <87fzhryxdc.fsf@windlord.stanford.edu> Subject: New NNTP draft -- Sections 1-3 Date: Fri, 17 Oct 2003 21:37:35 -0700 From: Russ Allbery <rra@stanford.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!text1.nnrp.aus1!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!199.184.165.233!feed2.news.rcn.net!rcn!logbridge.uoregon.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail Newsgroups: news.software.nntp Organization: The Eyrie Lines: 609 NNTP-Posting-Host: windlord.stanford.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.Stanford.EDU 1066451857 8163 171.64.19.147 (18 Oct 2003 04:37:37 GMT) X-Complaints-To: news@news.stanford.edu User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Common Lisp, linux) Cancel-Lock: sha1:NpSdmS5nMcwgt4aYp13bTgA3nfc=