⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idnntpserver.pas

📁 delphi indy9.0.18组件包
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  end;
end;

(*
6.1 LIST EXTENSIONS

6.1.1 Usage

   This command is optional.

   This command MUST NOT be pipelined.

   Syntax
      LIST EXTENSIONS

   Responses
      202   Extension list follows (multiline)
      402   Server has no extensions
      503   Extension information not available


6.1.2 Description

   The LIST EXTENSIONS command allows a client to determine which
   extensions are supported by the server.  This command MUST be
   implemented by any server that implements any extensions defined in
   this document.

   To discover what extensions are available, an NNTP client SHOULD
   query the server early in the session for extensions information by
   issuing the LIST EXTENSIONS command.  This command MAY be issued at
   anytime during a session.  It is not required that the client issues
   this command before attempting to make use of any extension.  The
   response generated by this command MAY change during a session
   because of other state information.  However, an NNTP client MUST NOT
   cache (for use in another session) any information returned if the
   LIST EXTENSIONS command succeeds.  That is, an NNTP client is only
   able to get the current and correct information concerning available
   extensions during a session by issuing a LIST EXTENSIONS command
   during that session and processing that response.

   The list of extensions is returned as a multi-line response following
   the 202 response code.  Each extension is listed on a separate line;
   the line MUST begin with an extension-label and optionally one or
   more parameters (separated by single spaces).  The extension-label
   and the meaning of the parameters are specified as part of the
   definition of the extension.  The extension-label MUST be in
   uppercase.

   The server MUST NOT list the same extension twice in the response,
   and MUST list all supported extensions.  The order in which the
   extensions are listed is not significant.  The server need not even
   consistently return the same order.  If the server does not support
   any extensions, a 402 response SHOULD be returned, but it MAY instead
   return an empty list.

   Following a 503 response an extension might still be available, and
   the client MAY attempt to use it.
*)
procedure TIdNNTPServer.CommandListExtensions(ASender: TIdCommand);
begin
  ASender.Reply.SetReply(202, 'Extensions supported:'); {do not localize}
  ASender.SendReply;
  if Assigned(FOnXHdr) then begin
    ASender.Thread.Connection.WriteLn('HDR');  {do not localize}
  end;
  if Assigned(OnXOver) then begin
    ASender.Thread.Connection.WriteLn('OVER');  {do not localize}
  end;
  if Assigned(FOnCheckListGroup) and Assigned(FOnListGroup) then begin
    ASender.Thread.Connection.WriteLn('LISTGROUP'); {do not localize}
  end;
  if Assigned(OnListActiveGroups) then begin
    ASender.Thread.Connection.WriteLn('LIST ACTIVE'); {do not localize}
  end;
  if Assigned(OnListActiveGroupTimes) then begin
    ASender.Thread.Connection.WriteLn('LIST ACTIVE.TIMES'); {do not localize}
  end;
  if Assigned(OnListDescriptions) then begin
    ASender.Thread.Connection.WriteLn('LIST NEWSGROUPS'); {do not localize}
  end;
  if Assigned(OnListDistributions) then begin
    ASender.Thread.Connection.WriteLn('LIST DISTRIBUTIONS'); {do not localize}
  end;
  if (DistributionPatterns.Count > 0) then begin
    ASender.Thread.Connection.WriteLn('LIST DISTRIB.PATS'); {do not localize}
  end;
  if Assigned(OnListHeaders) or (OverviewFormat.Count > 0) then begin
    ASender.Thread.Connection.WriteLn('LIST HEADERS'); {do not localize}
  end;
  if Assigned(OnListSubscriptions) then begin
    ASender.Thread.Connection.WriteLn('LIST SUBSCRIPTIONS'); {do not localize}
  end;
  if Assigned(OnListExtensions) then begin
    OnListExtensions(TIdNNTPThread(ASender.Thread));
  end;
  ASender.Thread.Connection.WriteLn('.');
end;

procedure TIdNNTPServer.CommandListGroup(ASender: TIdCommand);
var
  LThread : TIdNNTPThread;
  LGroup : String;
  LFirstIdx : Integer;
  LCanJoin : Boolean;
begin
  if not Assigned(OnCheckListGroup) or not Assigned(FOnListGroup) then
  begin
    ASender.Reply.NumericCode := 502;
    Exit;
  end;
  if not AuthRequired(ASender) then begin
    LThread := TIdNNTPThread(ASender.Thread);
    LGroup := Trim(ASender.UnparsedParams);
    if Length(LGroup) = 0 then
    begin
      LGroup := LThread.CurrentGroup;
    end;
    LCanJoin := False;
    if Length(LGroup) <> 0 then begin
      FOnCheckListGroup(LThread, LGroup, LCanJoin, LFirstIdx);
    end;
    if LCanJoin then
    begin
      LThread.FCurrentGroup := LGroup;
      LThread.FCurrentArticle := LFirstIdx;
      ASender.SendReply;
      FOnListGroup(LThread);
      ASender.Thread.Connection.WriteLn('.');
    end
    else
    begin
      ASender.Reply.SetReply(412, 'Not currently in newsgroup');
    end;
  end;
end;

(*
8.6.2 LIST HEADERS

8.6.2.1 Usage

   Syntax
      LIST HEADERS

   Responses
      215   Header and metadata list follows (multiline)


8.6.2.2 Description

   The LIST HEADERS command returns a list of headers and metadata items
   that may be retrieved using the HDR command.

   The information is returned as a multi-line response following the
   215 response code and contains one line for each header or metadata
   item name (excluding the colon in the former case). If the
   implementation allows any header to be retrieved (also indicated by
   the "ALL" argument to the extension label) it MUST NOT include any
   header names in the list but MUST include the special entry ":" (a
   single colon on its own); it MUST still list any metadata items that
   are available. The order of items in the list is not significant; the
   server need not even consistently return the same order. The list MAY
   be empty (though in this circumstance there is little point in
   providing the extension).

   An implementation that also supports the OVER extension SHOULD at
   least permit all the headers and metadata items listed in the output
   from the LIST OVERVIEW.FMT command.

8.6.2.3 Examples

   Example of an implementation providing access to only a few headers:

      [C] LIST EXTENSIONS
      [S] 202 extensions supported:
      [S] HDR
      [S] .
      [C] LIST HEADERS
      [S] 215 headers supported:
      [S] Subject
      [S] Message-ID
      [S] Xref
      [S] .

   Example of an implementation providing access to the same fields as
   the first example in Section 8.5.2.3:

      [C] LIST EXTENSIONS
      [S] 202 extensions supported:
      [S] OVER
      [S] HDR
      [S] .
      [C] LIST HEADERS
      [S] 215 headers and metadata items supported:
      [S] Date
      [S] Distribution
      [S] From
      [S] Message-ID
      [S] References
      [S] Subject
      [S] Xref
      [S] :bytes
      [S] :lines
      [S] .

   Example of an implementation providing access to all headers:

      [C] LIST EXTENSIONS
      [S] 202 extensions supported:
      [S] HDR ALL
      [S] .
      [C] LIST HEADERS
      [S] 215 metadata items supported:
      [S] :
      [S] :lines
      [S] :bytes
      [S] :x-article-number
      [S] .

*)
procedure TIdNNTPServer.CommandListHeaders(ASender: TIdCommand);
begin
  if not Assigned(OnListHeaders) and (OverviewFormat.Count = 0) then begin
    ASender.Reply.NumericCode := 500;
    Exit;
  end;
  ASender.Reply.SetReply(215, 'Headers and metadata items supported:'); {do not localize}
  ASender.SendReply;
  if Assigned(OnListHeaders) then begin
    OnListHeaders(TIdNNTPThread(ASender.Thread));
    ASender.Thread.Connection.WriteLn('.');
  end else begin
    ASender.Thread.Connection.WriteRFCStrings(OverviewFormat);
  end;
end;

(*
2. Newsreader Extensions

2.1.7 LIST OVERVIEW.FMT

   LIST OVERVIEW.FMT

   The overview.fmt file is maintained by some news transport systems to
   contain the order in which header information is stored in the
   overview databases for each news group.  When executed, news article
   header fields are displayed one line at a time in the order in which
   they are stored in the overview database [5] following the 215
   response.  When display is completed, the server will send a period
   on a line by itself.  If the information is not available, the server
   will return the 503 response.

   Please note that if the header has the word "full" (without quotes)
   after the colon, the header's name is prepended to its field in the
   output returned by the server.

   Many newsreaders work better if Xref: is one of the optional fields.

   It is STRONGLY recommended that this command be implemented in any
   server that implements the XOVER command.  See section 2.8 for more
   details about the XOVER command.

2.1.7.1 Responses

      215 information follows
      503 program error, function not performed
*)
procedure TIdNNTPServer.CommandListOverview(ASender: TIdCommand);
begin
  if (OverviewFormat.Count > 0) then begin
    ASender.Reply.SetReply(215, 'information follows');
    ASender.Response.Assign(OverviewFormat);
  end else begin
    ASender.Reply.NumericCode := 503;
  end;
end;

(*
2. Newsreader Extensions

2.1.8 LIST SUBSCRIPTIONS

   LIST SUBSCRIPTIONS

   This command is used to get a default subscription list for new users
   of this server.  The order of groups is significant.

   When this list is available, it is preceded by the 215 response and
   followed by a period on a line by itself.  When this list is not
   available, the server returns a 503 response code.

2.1.8.1 Responses

      215 information follows
      503 program error, function not performed

*)
procedure TIdNNTPServer.CommandListSubscriptions(ASender: TIdCommand);
begin
  if not Assigned(OnListSubscriptions) then begin
    ASender.Reply.NumericCode := 503;
    Exit;
  end;
  if not AuthRequired(ASender) then begin
    ASender.SendReply;
    OnListSubscriptions(TIdNNTPThread(ASender.Thread));
    ASender.Thread.Connection.WriteLn('.');
  end;
end;

(*
2.3 MODE READER

   MODE READER is used by the client to indicate to the server that it
   is a news reading client.  Some implementations make use of this
   information to reconfigure themselves for better performance in
   responding to news reader commands.  This command can be contrasted
   with the SLAVE command in RFC 977, which was not widely implemented.
   MODE READER was first available in INN.

2.3.1 Responses

      200 Hello, you can post
      201 Hello, you can't post
*)
procedure TIdNNTPServer.CommandModeReader(ASender: TIdCommand);
begin
  TIdNNTPThread(ASender.Thread).FModeReader := True;
  ASender.Reply.NumericCode := 200;
end;

(*
3.7.  The NEWGROUPS command

3.7.1.  NEWGROUPS

   NEWGROUPS date time [GMT] [<distributions>]

   A list of newsgroups created since <date and time> will be listed in
   the same format as the LIST command.

   The date is sent as 6 digits in the format YYMMDD, where YY is the
   last two digits of the year, MM is the two digits of the month (with
   leading zero, if appropriate), and DD is the day of the month (with
   leading zero, if appropriate).  The closest century is assumed as
   part of the year (i.e., 86 specifies 1986, 30 specifies 2030, 99 is
   1999, 00 is 2000).

   Time must also be specified.  It must be as 6 digits HHMMSS with HH
   being hours on the 24-hour clock, MM minutes 00-59, and SS seconds
   00-59.  The time is assumed to be in the server's timezone unless the
   token "GMT" appears, in which case both time and date are evaluated
   at the 0 meridian.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -