Permalink
Browse files

implements minimal error handling in THttpApiWebSocketConnection

  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Nov 20, 2017
1 parent 9544d5f commit cb3756c7ca4271227d9edb16dc69fe0230daad8c
Showing with 12 additions and 19 deletions.
  1. +9 −16 SynCrtSock.pas
  2. +1 −1 SynopseCommit.inc
  3. +2 −2 compilFPC.bat
@@ -8767,10 +8767,12 @@ procedure THttpApiWebSocketConnection.ReadData(const aBuf: WEB_SOCKET_BUFFER_DAT
var Err: HRESULT;
fBytesRead: cardinal;
begin
if fWSHandle = nil then
exit;
Err := Http.ReceiveRequestEntityBody(fProtocol.fServer.FReqQueue, fOpaqueHTTPRequestId, 0,
aBuf.pbBuffer, aBuf.ulBufferLength, fBytesRead, @self.fOverlapped);
case Err of
ERROR_HANDLE_EOF: ; // todo: close connection
ERROR_HANDLE_EOF: Disconnect;
ERROR_IO_PENDING: ; //
NO_ERROR: ;//
else
@@ -8783,6 +8785,8 @@ procedure THttpApiWebSocketConnection.WriteData(const aBuf: WEB_SOCKET_BUFFER_DA
httpSendEntity: HTTP_DATA_CHUNK_INMEMORY;
bytesWrite: Cardinal;
begin
if fWSHandle = nil then
exit;
bytesWrite := 0;
httpSendEntity.DataChunkType := hctFromMemory;
httpSendEntity.pBuffer := aBuf.pbBuffer;
@@ -8791,7 +8795,7 @@ procedure THttpApiWebSocketConnection.WriteData(const aBuf: WEB_SOCKET_BUFFER_DA
HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA or HTTP_SEND_RESPONSE_FLAG_MORE_DATA,
1, @httpSendEntity, bytesWrite, nil, nil, @fProtocol.fServer.fSendOverlaped);
case Err of
ERROR_HANDLE_EOF: ; // todo: close connection
ERROR_HANDLE_EOF: Disconnect;
ERROR_IO_PENDING: ; //
NO_ERROR: ;//
else
@@ -8817,29 +8821,18 @@ procedure THttpApiWebSocketConnection.CheckIsActive;
end;
procedure THttpApiWebSocketConnection.Disconnect;
var Err: HRESULT;
var //Err: HRESULT; //todo: handle error
httpSendEntity: HTTP_DATA_CHUNK_INMEMORY;
bytesWrite: Cardinal;
begin
WebSocketAPI.AbortHandle(fWSHandle);
WebSocketAPI.DeleteHandle(fWSHandle);
fWSHandle := nil;
httpSendEntity.DataChunkType := hctFromMemory;
httpSendEntity.pBuffer := nil;
httpSendEntity.BufferLength := 0;
Err := Http.SendResponseEntityBody(fProtocol.fServer.fReqQueue, fOpaqueHTTPRequestId,
HTTP_SEND_RESPONSE_FLAG_DISCONNECT,
1, @httpSendEntity, bytesWrite, nil, nil, nil);
// todo: check Err
case Err of
ERROR_HANDLE_EOF: ; // todo: close connection
ERROR_IO_PENDING: ; //
NO_ERROR: ;//
else
// todo: close connection
end;
{Err :=} Http.SendResponseEntityBody(fProtocol.fServer.fReqQueue, fOpaqueHTTPRequestId,
HTTP_SEND_RESPONSE_FLAG_DISCONNECT, 1, @httpSendEntity, bytesWrite, nil, nil, nil);
end;
procedure THttpApiWebSocketConnection.BeforeRead;
@@ -1 +1 @@
'1.18.3983'
'1.18.3984'
@@ -1,8 +1,8 @@
@echo off
set lib=d:\dev\lib
set bin=z:\tempbuild\fpc
set fpc=c:\fpcupdeluxe\fpc\bin\i386-win32\fpc.exe
set bin=d:\dev\lib\tempbuild\fpc
set fpc=c:\np\fpc\bin\i386-win32\fpc.exe
if exist %fpc% (

0 comments on commit cb3756c

Please sign in to comment.