Skip to content

Commit

Permalink
- Switch to block-based processing of http-content
Browse files Browse the repository at this point in the history
git-svn-id: trunk@49359 -
  • Loading branch information
JoostVanDerSluis committed May 13, 2021
1 parent 022a9b2 commit 6db4ab5
Show file tree
Hide file tree
Showing 9 changed files with 1,843 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4875,6 +4875,12 @@ packages/fcl-web/tests/cgigateway.lpi svneol=native#text/plain
packages/fcl-web/tests/cgigateway.pp svneol=native#text/plain
packages/fcl-web/tests/fpcunithpack.lpi svneol=native#text/plain
packages/fcl-web/tests/fpcunithpack.lpr svneol=native#text/plain
packages/fcl-web/tests/integrationtests/README.md svneol=native#text/markdown
packages/fcl-web/tests/integrationtests/UploadFile1.txt svneol=native#text/plain
packages/fcl-web/tests/integrationtests/UploadFile2.txt svneol=native#text/plain
packages/fcl-web/tests/integrationtests/UploadFile3.txt svneol=native#text/plain
packages/fcl-web/tests/integrationtests/fcgi_dump_request.pp svneol=native#text/pascal
packages/fcl-web/tests/integrationtests/fcl-web_integrationtests.jmx svneol=native#text/xml
packages/fcl-web/tests/tchttproute.pp svneol=native#text/plain
packages/fcl-web/tests/testcgiapp.lpi svneol=native#text/plain
packages/fcl-web/tests/testcgiapp.pp svneol=native#text/plain
Expand Down
36 changes: 30 additions & 6 deletions packages/fcl-web/src/base/custfcgi.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
FUR: TUnknownRecordEvent;
FLog : TLogEvent;
FSTDin : String;
FSTDinRead: Integer;

FRequestHeadersInitialized: Boolean;
FStreamingContentReceived: Boolean;
Protected
function DoGetCGIVar(AVarName: String): String; override;
procedure GetNameValuePairsFromContentRecord(const ARecord : PFCGI_ContentRecord; NameValueList : TStrings); virtual;
Expand Down Expand Up @@ -247,6 +251,7 @@ destructor TFCGIRequest.Destroy;

function TFCGIRequest.ProcessFCGIRecord(AFCGIRecord: PFCGI_Header): boolean;
var cl,rcl : Integer;
State: TContentStreamingState;
begin
Result := False;
case AFCGIRecord^.reqtype of
Expand All @@ -257,6 +262,7 @@ function TFCGIRequest.ProcessFCGIRecord(AFCGIRecord: PFCGI_Header): boolean;
// log(etDebug,Format('Begin request body role & flags: %d %d',[Beton(Role),Flags]));
end;
FCGI_PARAMS : begin
FRequestHeadersInitialized := False;
if AFCGIRecord^.contentLength=0 then
Result := False
else
Expand All @@ -267,14 +273,34 @@ function TFCGIRequest.ProcessFCGIRecord(AFCGIRecord: PFCGI_Header): boolean;
end;
end;
FCGI_STDIN : begin
if not FRequestHeadersInitialized then
begin
InitHeaderRequestVars;
FRequestHeadersInitialized := True;
end;
Result:=AFCGIRecord^.contentLength=0;
if not Result then
begin
cl := length(FSTDin);
rcl := BetoN(PFCGI_ContentRecord(AFCGIRecord)^.header.contentLength);
SetLength(FSTDin, rcl+cl);
move(PFCGI_ContentRecord(AFCGIRecord)^.ContentData[0],FSTDin[cl+1],rcl);
InitContent(FSTDin);
if FStreamingContentReceived then
State := cssData
else
State := cssStart;
FStreamingContentReceived := True;

ProcessStreamingContent(State, PFCGI_ContentRecord(AFCGIRecord)^.ContentData[0], rcl);
end
else
begin
if not FStreamingContentReceived then
begin
ProcessStreamingContent(cssStart, PFCGI_ContentRecord(AFCGIRecord)^.ContentData[0], 0);
ProcessStreamingContent(cssEnd, PFCGI_ContentRecord(AFCGIRecord)^.ContentData[0], 0);
end
else
begin
ProcessStreamingContent(cssEnd, PFCGI_ContentRecord(AFCGIRecord)^.ContentData[0], 0);
end;
end;
end;
else
Expand All @@ -284,8 +310,6 @@ function TFCGIRequest.ProcessFCGIRecord(AFCGIRecord: PFCGI_Header): boolean;
if poFailonUnknownRecord in FPO then
TFCgiHandler.DoError('Unknown FASTCGI record type: %s',[AFCGIRecord^.reqtype]);
end;
if Result then
InitRequestVars;
end;

function TFCGIRequest.DoGetCGIVar(AVarName: String): String;
Expand Down
Loading

0 comments on commit 6db4ab5

Please sign in to comment.