Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajuste na uRESTDWBasic e uRESTDWFphttpBase #333

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions CORE/Source/Basic/uRESTDWBasic.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3045,10 +3045,19 @@ procedure TRESTClientPoolerBase.SetIpVersion(IpV: TRESTDWClientIpVersions);
If vDefaultPage.Count > 0 Then
vReplyString := vDefaultPage.Text
Else
vReplyString := TServerStatusHTML;
vErrorCode := 200;
ContentType := 'text/html';
End
if vErrorMessage <> EmptyStr then
begin
vReplyString := vErrorMessage;
vErrorCode := 401;
ContentType := 'text/html';
end
else
begin
vReplyString := TServerStatusHTML;
vErrorCode := 200;
ContentType := 'text/html';
End
end
Else
Begin
If vEncoding = esUtf8 Then
Expand Down
31 changes: 30 additions & 1 deletion CORE/Source/Sockets/Fphttp/uRESTDWFphttpBase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,39 @@ procedure TRESTDWFphttpServicePooler.ExecRequest(Sender: TObject;
procedure ParseHeader;
var
I: Integer;
begin
s: string;
sl: TStringList;

begin
sl := nil;

HeaderList.NameValueSeparator:= ':';
for I := 0 to Pred(ARequest.FieldCount) do
HeaderList.AddPair(ARequest.FieldNames[I], ARequest.FieldValues[I] );

for I := 0 to Pred(ARequest.CustomHeaders.Count) do
HeaderList.AddPair(ARequest.CustomHeaders.Names[I], ARequest.CustomHeaders.ValueFromIndex[I] );

s := ARequest.GetHTTPVariable(hvURL);
sl := TStringList.Create;
try
if (Pos('?', s) > 0)then
begin
s := StringReplace(s, '?', '', [rfReplaceAll]);
s := StringReplace(s, '/', '', []);
sl.Delimiter := '&';
sl.StrictDelimiter := True;
sl.DelimitedText := s;
for i := 0 to sl.Count - 1 do
begin
s := sl[i];
if Pos('=', s) > 0 then
HeaderList.AddPair(Copy(s, 1, Pos('=', s) - 1) , Copy(s, Pos('=', s) + 1, Length(s) - Pos('=', s)));
end;
end;
finally
FreeAndNil(sl);
end;
end;

procedure SetReplyCORS;
Expand Down