Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   TIdHTTPServer: Programmabsturz bei langwieriger ResponseInfo-Berechnung (https://www.delphipraxis.net/178295-tidhttpserver-programmabsturz-bei-langwieriger-responseinfo-berechnung.html)

MStoll 2. Jan 2014 20:11

AW: TIdHTTPServer: Programmabsturz bei langwieriger ResponseInfo-Berechnung
 
Das müsste so reichen:

Delphi-Quellcode:
unit http;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,

  IdHTTPServer, IdCustomHTTPServer, IdContext, IdSocketHandle, IdGlobal;

type
  THTTPServer = class(TIdHTTPServer)
  private
    _newPort : Word;
  public
    constructor Create(port : Word);
    procedure InitComponent; override;
    procedure DoCommandGet(AContext: TIdContext;
      ARequestInfo: TIdHTTPRequestInfo;
      AResponseInfo: TIdHTTPResponseInfo); override;
  end;

implementation

constructor THTTPServer.Create(port: Word);
begin
  _newPort := port;

  inherited Create;
end;  

procedure THTTPServer.InitComponent;
var
  Binding: TIdSocketHandle;
begin
  inherited;

  Bindings.Clear;
  Binding := Bindings.Add;
  Binding.IP := '0.0.0.0';
  Binding.Port := _newPort;
  Binding.IPVersion := Id_IPv4;
end;

procedure THTTPServer.DoCommandGet(AContext: TIdContext;
      ARequestInfo: TIdHTTPRequestInfo;
      AResponseInfo: TIdHTTPResponseInfo);
begin
  AResponseInfo.ContentText := 'Test';
  Sleep(4000);
end;

end.
Als Client habe ich Google Chrome verwendet (mit ein paar Tabs, die den Webserver anfragen). Aber auch jeder andere Browser sollte es tun. Spätestens, wenn du in den Tabs schnell ein paar mal F5 drückst, sollte das Server-Programm abstürzen.

Ich bin mittlerweile bei Synapse. Damit scheint das ganze zu funktionieren (erste Einschätzung).


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:49 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz