Permalink
Browse files

slight optimizations in the HTTP socket server

- no functional change
  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Jan 3, 2019
1 parent 12670fb commit 8f3dffadde796bbce3fe59fdf9792c2c46163708
Showing with 25 additions and 20 deletions.
  1. +24 −19 SynCrtSock.pas
  2. +1 −1 SynopseCommit.inc
@@ -3497,7 +3497,7 @@ procedure GetNextLine(var P: PAnsiChar; var result: SockString);
if P=nil then
result := '' else begin
S := P;
while S^>=' ' do
while S^>=' ' do // break on any control char
inc(S);
SetString(result,P,S-P);
while (S^<>#0) and (S^<' ') do inc(S); // ignore e.g. #13 or #10
@@ -6430,7 +6430,7 @@ procedure THttpSocket.GetHeader;
if s='' then
break; // headers end with a void line
if length(Headers)<=n then
SetLength(Headers,n+10);
SetLength(Headers,n+n shr 3+10);
Headers[n] := s;
inc(n);
P := pointer(s);
@@ -6595,8 +6595,8 @@ procedure THttpServerSocket.InitRequest(aClientSock: TSocket);
function THttpServerSocket.GetRequest(withBody: boolean=true): boolean;
var P: PAnsiChar;
i, L: integer;
H: ^PAnsiChar;
pH: PAnsiChar;
H: ^PByteArray;
up: PByteArray;
maxtix, status: cardinal;
reason: SockString;
begin
@@ -6618,29 +6618,34 @@ function THttpServerSocket.GetRequest(withBody: boolean=true): boolean;
// get headers and content
GetHeader;
if fServer<>nil then begin // e.g. =nil from TRTSPOverHTTPServer
up := pointer(@NormToUpper);
L := length(fServer.fRemoteIPHeaderUpper);
if L<>0 then begin
if L<>0 then begin
H := pointer(Headers);
for i := 1 to length(Headers) do
if IdemPChar(H^,pointer(fServer.fRemoteIPHeaderUpper)) and (H^[L]=':') then begin
repeat inc(L) until H^[L]<>' ';
if H^[L]<>#0 then
fRemoteIP := H^+L;
break;
end else
inc(H);
if IdemPCharUp(H^,pointer(fServer.fRemoteIPHeaderUpper),up) and
(H^[L]=ord(':')) then begin
P := pointer(@H^[L]);
repeat inc(P) until P^<>' ';
if P^<>#0 then
fRemoteIP := P^;
break;
end else
inc(H);
end;
// remote connection ID
L := length(fServer.fRemoteConnIDHeaderUpper);
if L<>0 then begin
if L<>0 then begin
H := pointer(Headers);
for i := 1 to length(Headers) do
if IdemPChar(H^,pointer(fServer.fRemoteConnIDHeaderUpper)) and (H^[L]=':') then begin
pH := H^+L+1; while (pH^=' ') do inc(pH);
fRemoteConnectionID := GetNextItemUInt64(pH);
break;
end else
inc(H);
if IdemPCharUp(H^,pointer(fServer.fRemoteConnIDHeaderUpper),up) and
(H^[L]=ord(':')) then begin
P := pointer(@H^[L]);
repeat inc(P) until P^<>' ';
fRemoteConnectionID := GetNextItemUInt64(P);
break;
end else
inc(H);
end;
end;
if ConnectionClose then
@@ -1 +1 @@
'1.18.4937'
'1.18.4938'

0 comments on commit 8f3dffa

Please sign in to comment.