httpapp.pp 4.6 KB

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