httpapp.pp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. {
  2. $Id$
  3. This file is part of the Free Component Library (FCL)
  4. Copyright (c) 1998 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit httpapp;
  13. interface
  14. uses
  15. sysutils,classes,syncobjs;
  16. const
  17. DateFormat = 'ddd, dd mmm yyyy hh:mm:ss';
  18. MAX_STRINGS = 12;
  19. MAX_INTEGERS = 1;
  20. MAX_DATETIMES = 3;
  21. type
  22. TCharSet = set of Char;
  23. TMethodType = (mtAny,mtGet,mtPut,mtPost,mtHead);
  24. TWebApp = class(TComponent)
  25. protected
  26. function ActivateWebModule : TDataModule;
  27. procedure DeactivateWebModule(DataModule : TDataModule);
  28. procedure DoHandleException(E : Exception);dynamic;
  29. function HandleRequest(Request : TWebRequest;Response : TWebResponse) : Boolean;
  30. public
  31. constructor Create(AOwner : TComponent);override;
  32. procedure CreateForm(InstanceClass: TComponentClass;var Reference);virtual;
  33. destructor Destroy;override;
  34. procedure Initialize;virtual;
  35. procedure Run;virtual;
  36. end;
  37. function DosPathToUnixPath(const Path : string) : string;
  38. function UnixPathToDosPath(const Path : string) : string;
  39. function HTTPDecode(const str : String) : string;
  40. function HTTPEncode(const str : String) : string;
  41. function ParseDate(const DateStr : string) : TDateTime;
  42. procedure ExtractHTTPFields(Separators,WhiteSpace : TCharSet;
  43. Content : PChar;Strings : TStrings);
  44. procedure ExtractHeaderFields(Separators,WhiteSpace : TCharSet;
  45. Content: PChar;Strings : TStrings;Decode : Boolean);
  46. function StatusString(StatusCode : Integer) : string;
  47. const
  48. Application : TWebApp = nil;
  49. implementation
  50. function TWebApp.ActivateWebModule : TDataModule;
  51. begin
  52. end;
  53. procedure TWebApp.DeactivateWebModule(DataModule : TDataModule);
  54. begin
  55. end;
  56. procedure TWebApp.DoHandleException(E : Exception);
  57. begin
  58. end;
  59. function TWebApp.HandleRequest(Request : TWebRequest;Response : TWebResponse) : Boolean;
  60. begin
  61. end;
  62. constructor TWebApp.Create(AOwner : TComponent);
  63. begin
  64. end;
  65. procedure TWebApp.CreateForm(InstanceClass: TComponentClass;var Reference);
  66. begin
  67. end;
  68. destructor TWebApp.Destroy;
  69. begin
  70. end;
  71. procedure TWebApp.Initialize;
  72. begin
  73. end;
  74. procedure TWebApp.Run;
  75. begin
  76. end;
  77. function DosPathToUnixPath(const Path : string) : string;
  78. var
  79. i : integer;
  80. begin
  81. Result:=Path;
  82. for i:=1 to Length(Result) do
  83. if Result[i]='\' then
  84. Result[i]:='/';
  85. end;
  86. function UnixPathToDosPath(const Path : string) : string;
  87. var
  88. i : integer;
  89. begin
  90. Result:=Path;
  91. for i:=1 to Length(Result) do
  92. if Result[i]='/' then
  93. Result[i]:='\';
  94. end;
  95. function HTTPDecode(const str : String) : string;
  96. begin
  97. end;
  98. function HTTPEncode(const str : String) : string;
  99. const
  100. noconvert = ['A'..'Z','a'..'z','*','@','.',
  101. '.','_','-','0'..'9','$','!','''','(',')'];
  102. const
  103. hex2str : array[0..15] of char = '0123456789ABCDEF';
  104. var
  105. i : integer;
  106. c : char;
  107. s : shortstring;
  108. begin
  109. // allocate some space for the result
  110. SetLength(Result,Length(str));
  111. for i:=1 to length(str) do
  112. begin
  113. c:=str[i];
  114. if c in noconvert then
  115. Result:=Result+c;
  116. else if c=' ' then
  117. Result:=Result+'+'
  118. else
  119. Result:=Result+'%'+
  120. hex2str[ord(c) shr 4]+
  121. hex2str[ord(c) and $f];
  122. end;
  123. end;
  124. function ParseDate(const DateStr : string) : TDateTime;
  125. begin
  126. end;
  127. procedure ExtractHTTPFields(Separators,WhiteSpace : TCharSet;
  128. Content : PChar;Strings : TStrings);
  129. begin
  130. ExtractHeaderFields(Separators,WhiteSpace,Content,Strings,True);
  131. end;
  132. procedure ExtractHeaderFields(Separators,WhiteSpace : TCharSet;
  133. Content: PChar;Strings : TStrings;Decode : Boolean);
  134. begin
  135. end;
  136. function StatusString(StatusCode : Integer) : string;
  137. begin
  138. end;
  139. end.
  140. {
  141. $Log$
  142. Revision 1.2 2000-07-13 11:33:07 michael
  143. + removed logs
  144. }