Ignore:
Timestamp:
Sep 13, 2010, 11:20:24 AM (14 years ago)
Author:
george
Message:
  • Přidáno: Druhá varianta projektu pro sestavení TCP serveru.
  • Přidáno: Vlastní obsluha vyjímek a zobrazení ve HTTP tvaru.
  • Opraveno: Zpracování session třídy THTTPSessionStorageMySQL.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        22UConfig.pas
        33bin
         4lib
  • trunk/WebServer/UHTTPServerCGI.pas

    r32 r33  
    1818    constructor Create;
    1919    destructor Destroy; override;
    20     procedure SysInfo;
     20    procedure ServerInfo(HandlerData: THTTPHandlerData); override;
    2121  end;
    2222
     
    5050
    5151    // Process cookies
    52     if Request.Headers.IndexOfName('Cookie') <> -1 then
    53       Request.Cookies.Parse(Request.Headers.Values['Cookie']);
     52    if EnvVars.IndexOfName('HTTP_COOKIE') <> -1 then
     53      Request.Cookies.Parse(EnvVars.Values['HTTP_COOKIE']);
    5454
    5555    // Parse query string
     
    6464        Length(EnvVars.Values['REQUEST_URI'])));
    6565
     66    // Load session variables
     67    if Assigned(SessionStorage) then
     68      SessionStorage.Load(HandlerData);
     69
    6670    Response.Stream.Clear;
    6771    Response.Headers.Values['Content-type'] := 'text/html';
    6872
     73    // Execute content handler
    6974    if Assigned(OnRequest) then OnRequest(HandlerData)
    7075      else raise EEmptyHTTPHandler.Create(SEmptyHTTPHandler);
    7176
     77     // Store session variables
     78    if Assigned(SessionStorage) then
     79      SessionStorage.Save(HandlerData);
     80
    7281    with Response do begin
     82      // Generate cookies
     83      for I := 0 to Cookies.Count - 1 do
     84        Headers.Add('Set-Cookie' + Headers.NameValueSeparator + Cookies.Names[I] + '=' + Cookies.ValueFromIndex[I]);
     85        // + ';path=/;expires=' + RFC822DateTime(Now);
     86
    7387      // Generate headers
    7488      for I := 0 to Headers.Count - 1 do begin
    7589        WriteLn(Headers.Names[I] + ': ' + Headers.ValueFromIndex[I]);
    7690      end;
    77 
    78       // Generate cookies
    79       for I := 0 to Cookies.Count - 1 do
    80         Headers.Add('Set-Cookie' + Headers.NameValueSeparator + Cookies.Names[I] + '=' + Cookies.ValueFromIndex[I]);
    81         // + ';path=/;expires=' + RFC822DateTime(Now);
    8291
    8392      WriteLn; // Empty line header separator
     
    92101end;
    93102
    94 procedure THTTPServerCGI.SysInfo;
     103procedure THTTPServerCGI.ServerInfo(HandlerData: THTTPHandlerData);
    95104var
    96105  I: Integer;
    97106begin
    98 (*  Output.Add('<h4>Environment variables:</h4>');
    99   Output.Add('<table border="1">');
    100   for I := 0 to EnvVars.Count - 1 do begin
    101     Output.Add('<tr><td>' + EnvVars.Names[I] + '</td><td>' +
    102       EnvVars.ValueFromIndex[I] + '</td></tr>');
     107  inherited;
     108  with HandlerData, Response.Stream do begin
     109    WriteString('<h5>Environment variables:</h5>');
     110    WriteString('<table border="1">');
     111    for I := 0 to EnvVars.Count - 1 do begin
     112      WriteString('<tr><td>' + EnvVars.Names[I] + '</td><td>' +
     113        EnvVars.ValueFromIndex[I] + '</td></tr>');
     114    end;
     115    WriteString('</table>');
    103116  end;
    104   Output.Add('</table>');*)
    105117end;
    106118
Note: See TracChangeset for help on using the changeset viewer.