Ignore:
Timestamp:
Jan 4, 2012, 2:27:19 PM (12 years ago)
Author:
chronos
Message:
  • Added: Support for handling POST values in HTTPServer.
  • Fixed: TCP server to start listening and wait for termination.
  • Added: ServerType of WebApp as CGI or TCP.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Network/CoolWeb/WebServer/UHTTPServerTCP.pas

    r237 r311  
    2121    constructor Create(AOwner: TComponent); override;
    2222    destructor Destroy; override;
     23    procedure Run; override;
    2324  published
    2425    property MaxConnection: Integer read FMaxConnection write FMaxConnection;
     
    8889      SessionStorage.Load(HandlerData);
    8990
    90     Response.Stream.Clear;
     91    Response.Content.Clear;
    9192    Response.Headers.Values['Content-Type'] := 'text/html';
    9293
     
    100101    with Response do begin
    101102      SendString('HTTP/1.0 200 OK'#13#10);
    102       Headers.Values['Content-Length'] := IntToStr(Stream.Size);
     103      Headers.Values['Content-Length'] := IntToStr(Content.Size);
    103104      Headers.Values['Connection'] := 'close';
    104105      Headers.Values['Date'] := RFC822DateTime(Now);
     
    115116      end;
    116117      SendString(#13#10);
    117       SendBuffer(Stream.Memory, Stream.Size);
     118      SendBuffer(Content.Memory, Content.Size);
    118119      SendString(#13#10);
    119120    end;
     
    143144end;
    144145
     146procedure THTTPServerTCP.Run;
     147begin
     148  inherited Run;
     149  WriteLn('HTTP Server started in TCP mode.');
     150  WriteLn('Listen on ' + Socket.Address + ':' + IntToStr(Socket.Port));
     151  WriteLn('Press any key to terminate...');
     152  Socket.ThreadPool.TotalCount := MaxConnection;
     153  Socket.Active := True;
     154  ReadLn;
     155  WriteLn('Exiting');
     156end;
     157
    145158end.
    146159
Note: See TracChangeset for help on using the changeset viewer.