Changeset 139 for trunk/Packages/CoolWeb/WebServer
- Timestamp:
- Sep 9, 2022, 9:41:42 PM (2 years ago)
- Location:
- trunk/Packages/CoolWeb/WebServer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CoolWeb/WebServer/UHTTPServer.pas
r138 r139 43 43 44 44 THTTPResponse = class 45 StatusCode: string; 45 46 ContentType: string; 46 47 Content: TMemoryStreamEx; … … 123 124 SPageNotFound = 'Page %s not found.'; 124 125 126 const 127 StatusCodeNotFound = '404 Not Found'; 128 125 129 126 130 implementation … … 134 138 begin 135 139 with HandlerData, Response.Content do begin 136 //Response.Cookies.Values['Test'] := 'Halo';137 //Response.Cookies.Values['Test2'] := 'Halo2';138 139 //HTTPServer.SessionHandler.Variables.Values['Session1'] := 'Value1';140 //HTTPServer.SessionHandler.Variables.Values['Session2'] := 'Value2';141 142 140 WriteString('<a href="?ServerInfo">Refresh</a>'); 143 141 … … 192 190 begin 193 191 with HandlerData, Response.Content do begin 192 Response.StatusCode := StatusCodeNotFound; 194 193 WriteString('<html><body>' + Format(SPageNotFound, [Implode('/', Request.Path)]) + '</body></html>'); 195 194 end; … … 224 223 end else 225 224 with Response.Content do begin 226 //WriteLn(Format(SFileNotFound, [Request.Path.Implode('/', StrToStr)]));225 Response.StatusCode := StatusCodeNotFound; 227 226 WriteString('<html><body>' + Format(SFileNotFound, [Implode('/', Request.Path)]) + '</body></html>'); 228 227 end; … … 248 247 procedure THTTPResponse.Assign(Source: THTTPResponse); 249 248 begin 249 StatusCode := Source.StatusCode; 250 250 Content.Assign(Source.Content); 251 251 ContentType := Source.ContentType; … … 263 263 constructor THTTPResponse.Create; 264 264 begin 265 StatusCode := '200 OK'; 265 266 Content := TMemoryStreamEx.Create; 266 267 Cookies := TCookieList.Create; … … 291 292 begin 292 293 I := 0; 293 while (I < Count) and (TRequestHandler(Items[I]).Name <> AName) do Inc(I); 294 if I < Count then Result := TRequestHandler(Items[I]) else Result := nil; 294 while (I < Count) and (Items[I].Name <> AName) do Inc(I); 295 if I < Count then Result := Items[I] 296 else Result := nil; 295 297 end; 296 298 -
trunk/Packages/CoolWeb/WebServer/UHTTPServerTCP.pas
r138 r139 117 117 118 118 with Response do begin 119 SendString('HTTP/1.0 200 OK'#13#10);119 SendString('HTTP/1.0 ' + StatusCode + #13#10); 120 120 Headers.Add('Content-Length', IntToStr(Content.Size)); 121 121 Headers.Add('Connection', 'close'); -
trunk/Packages/CoolWeb/WebServer/UTurboPowerForm.pas
r137 r139 24 24 procedure AShowSourceExecute(Sender: TObject); 25 25 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 26 private27 { private declarations }28 26 public 29 27 HtmlSource: string;
Note:
See TracChangeset
for help on using the changeset viewer.