123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- {
- This file is part of the Free Component Library (FCL)
- Copyright (c) 1998 by Florian Klaempfl
- member of the Free Pascal development team
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- unit httpapp;
- interface
- uses
- sysutils,classes,syncobjs;
- const
- DateFormat = 'ddd, dd mmm yyyy hh:mm:ss';
- MAX_STRINGS = 12;
- MAX_INTEGERS = 1;
- MAX_DATETIMES = 3;
- type
- TCharSet = set of Char;
- TMethodType = (mtAny,mtGet,mtPut,mtPost,mtHead);
- TWebApp = class(TComponent)
- protected
- function ActivateWebModule : TDataModule;
- procedure DeactivateWebModule(DataModule : TDataModule);
- procedure DoHandleException(E : Exception);dynamic;
- function HandleRequest(Request : TWebRequest;Response : TWebResponse) : Boolean;
- public
- constructor Create(AOwner : TComponent);override;
- procedure CreateForm(InstanceClass: TComponentClass;var Reference);virtual;
- destructor Destroy;override;
- procedure Initialize;virtual;
- procedure Run;virtual;
- end;
- function DosPathToUnixPath(const Path : string) : string;
- function UnixPathToDosPath(const Path : string) : string;
- function HTTPDecode(const str : String) : string;
- function HTTPEncode(const str : String) : string;
- function ParseDate(const DateStr : string) : TDateTime;
- procedure ExtractHTTPFields(Separators,WhiteSpace : TCharSet;
- Content : PChar;Strings : TStrings);
- procedure ExtractHeaderFields(Separators,WhiteSpace : TCharSet;
- Content: PChar;Strings : TStrings;Decode : Boolean);
- function StatusString(StatusCode : Integer) : string;
- const
- Application : TWebApp = nil;
- implementation
- function TWebApp.ActivateWebModule : TDataModule;
- begin
- end;
- procedure TWebApp.DeactivateWebModule(DataModule : TDataModule);
- begin
- end;
- procedure TWebApp.DoHandleException(E : Exception);
- begin
- end;
- function TWebApp.HandleRequest(Request : TWebRequest;Response : TWebResponse) : Boolean;
- begin
- end;
- constructor TWebApp.Create(AOwner : TComponent);
- begin
- end;
- procedure TWebApp.CreateForm(InstanceClass: TComponentClass;var Reference);
- begin
- end;
- destructor TWebApp.Destroy;
- begin
- end;
- procedure TWebApp.Initialize;
- begin
- end;
- procedure TWebApp.Run;
- begin
- end;
- function DosPathToUnixPath(const Path : string) : string;
- var
- i : integer;
- begin
- Result:=Path;
- for i:=1 to Length(Result) do
- if Result[i]='\' then
- Result[i]:='/';
- end;
- function UnixPathToDosPath(const Path : string) : string;
- var
- i : integer;
- begin
- Result:=Path;
- for i:=1 to Length(Result) do
- if Result[i]='/' then
- Result[i]:='\';
- end;
- function HTTPDecode(const str : String) : string;
- begin
- end;
- function HTTPEncode(const str : String) : string;
- const
- noconvert = ['A'..'Z','a'..'z','*','@','.',
- '.','_','-','0'..'9','$','!','''','(',')'];
- const
- hex2str : array[0..15] of char = '0123456789ABCDEF';
- var
- i : integer;
- c : char;
- s : shortstring;
- begin
- // allocate some space for the result
- SetLength(Result,Length(str));
- for i:=1 to length(str) do
- begin
- c:=str[i];
- if c in noconvert then
- Result:=Result+c;
- else if c=' ' then
- Result:=Result+'+'
- else
- Result:=Result+'%'+
- hex2str[ord(c) shr 4]+
- hex2str[ord(c) and $f];
- end;
- end;
- function ParseDate(const DateStr : string) : TDateTime;
- begin
- end;
- procedure ExtractHTTPFields(Separators,WhiteSpace : TCharSet;
- Content : PChar;Strings : TStrings);
- begin
- ExtractHeaderFields(Separators,WhiteSpace,Content,Strings,True);
- end;
- procedure ExtractHeaderFields(Separators,WhiteSpace : TCharSet;
- Content: PChar;Strings : TStrings;Decode : Boolean);
- begin
- end;
- function StatusString(StatusCode : Integer) : string;
- begin
- end;
- end.
|