mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 11:20:23 +02:00
* Allow redirect to local URL (patch by Michal GawRycki, bug ID #34595)
git-svn-id: trunk@40395 -
This commit is contained in:
parent
090141a69c
commit
a49c17fb7d
@ -1376,7 +1376,7 @@ procedure TFPCustomHTTPClient.HTTPMethod(const AMethod, AURL: String;
|
|||||||
Stream: TStream; const AllowedResponseCodes: array of Integer);
|
Stream: TStream; const AllowedResponseCodes: array of Integer);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
M,L,NL : String;
|
M,L,NL,RNL : String;
|
||||||
RC : Integer;
|
RC : Integer;
|
||||||
RR : Boolean; // Repeat request ?
|
RR : Boolean; // Repeat request ?
|
||||||
|
|
||||||
@ -1399,17 +1399,22 @@ begin
|
|||||||
if (RC>MaxRedirects) then
|
if (RC>MaxRedirects) then
|
||||||
Raise EHTTPClient.CreateFmt(SErrMaxRedirectsReached,[RC]);
|
Raise EHTTPClient.CreateFmt(SErrMaxRedirectsReached,[RC]);
|
||||||
NL:=GetHeader(FResponseHeaders,'Location');
|
NL:=GetHeader(FResponseHeaders,'Location');
|
||||||
if Not Assigned(FOnRedirect) then
|
if Assigned(FOnRedirect) then
|
||||||
L:=NL
|
|
||||||
else
|
|
||||||
FOnRedirect(Self,L,NL);
|
FOnRedirect(Self,L,NL);
|
||||||
|
if (not IsAbsoluteURI(NL)) and ResolveRelativeURI(L,NL,RNL) then
|
||||||
|
NL:=RNL;
|
||||||
if (RedirectForcesGET(FResponseStatusCode)) then
|
if (RedirectForcesGET(FResponseStatusCode)) then
|
||||||
M:='GET';
|
M:='GET';
|
||||||
L:=NL;
|
|
||||||
// Request has saved cookies in sentcookies.
|
// Request has saved cookies in sentcookies.
|
||||||
FreeAndNil(FCookies);
|
if ParseURI(L).Host=ParseURI(NL).Host then
|
||||||
FCookies:=FSentCookies;
|
FreeAndNil(FSentCookies)
|
||||||
FSentCookies:=Nil;
|
else
|
||||||
|
begin
|
||||||
|
FreeAndNil(FCookies);
|
||||||
|
FCookies:=FSentCookies;
|
||||||
|
FSentCookies:=Nil;
|
||||||
|
end;
|
||||||
|
L:=NL;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (FResponseStatusCode=401) then
|
if (FResponseStatusCode=401) then
|
||||||
|
Loading…
Reference in New Issue
Block a user