CustomizeUserAgent

From 40tude Dialog Wiki

Customize User-Agent string

A little script done by Thomas Barghahn. With this script you are able to change any header and add a trailing text at the end of the Header (IMHO its only reasonable for the User-Agent string). If you found bugs feel free to contact the autor Thomas Barghahn (Th.Barghahn@t-online.de).


Example with User-Agent-Header:

"User-Agent: 40tude_Dialog/2.0.12.1de (1693fe98.335.147) (Simply the best usenet experience)"

If you like to add you're text at the end of the user-agent, please attend to the following abstract from draft-ietf-usefor-usefor-01.

User-Agent

The User-Agent header contains information about the user agent (typically a newsreader) generating the article for statistical purposes and tracing of standards violations to specific software needing correction. Although not one of the mandatory headers, posting agents SHOULD normally include it. It is also intended that this header be suitable for use in Email.

user-agent      =  "User-Agent:" SP 1*product CRLF
product         =  [CFWS] token [CFWS] [ "/" product-version ]
product-version =  [CFWS] token [CFWS]

program OnBeforeSendingMessage;

// Date: 2004/10/22

const
// set the header you want to change here, e.g. 'User-Agent'
    ChangeHeader = 'User-Agent:';
    AddOnChangeHeader = ' (Simply the best usenet experience)';

// change header in emails and/or postings
// set 'true' or 'false'
    ChangeInEmails=true;
    ChangeInNews=true;

procedure ChangeAnyHeader(Message:TStringlist;IsEmail:boolean);
var i:integer;
    s:string;
begin
  if ((IsEmail=true)  and (ChangeInEmails=true)) or
     ((IsEmail=false) and (ChangeInNews=true)) then
  begin
    s := Message.text;
    i := 1;
    while (Message.Strings[i]<>'') do
    begin
      if pos(ChangeHeader,Message.Strings[i]) = 1 then
      begin
       Message.Strings[i] := Message.Strings[i] + AddOnChangeHeader;
       s := Message.text; 
      end;
      i := i + 1;
    end; {end of while}
    message.text := s;
  end;
end;

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
  ChangeAnyHeader(Message,IsEmail);
  result:=true;
end;

begin
end.

René Fischer