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

idHttp - IPv6 - IPVersion-ProtocolSwitch on Redirect (HandleRedirects=true) #528

Open
tobfel opened this issue Mar 14, 2024 · 2 comments
Open
Labels
Element: HTTP Issues related to HTTP handling, TIdHTTP, TIdHTTPServer, TIdHTTPProxyServer, etc Status: Review Needed Issue needs further review to decide next status Type: Bug Issue is a bug in existing code

Comments

@tobfel
Copy link

tobfel commented Mar 14, 2024

First reqest is done via IPv6, but when the server response with 301, the RedirectUrl ist not called with the same IP-Protocol-Version.
Can be fixed via:

if Request.IPVersion=Id_IPv6 then
    begin
    with TIdURI.Create(LLocation) do
         begin
         URI := LLocation;
         IPVersion := Id_IPv6;
         LLocation := URI;
         Free;
         end;
    end;

in

function TIdHTTPProtocol.ProcessResponse(AIgnoreReplies: array of Int16): TIdHTTPWhatsNext;
...
after:
LLocation := Response.Location;
LMethod := Request.Method;
@tobfel tobfel added Status: Reported Issue has been reported for review Type: Bug Issue is a bug in existing code labels Mar 14, 2024
@rlebeau rlebeau added the Element: HTTP Issues related to HTTP handling, TIdHTTP, TIdHTTPServer, TIdHTTPProxyServer, etc label Mar 17, 2024
@rlebeau
Copy link
Member

rlebeau commented Mar 17, 2024

TIdURI is already being used to process the Request.URL inside of TIdCustomHTTP.PrepareRequest(), which is called just after LLocation is assigned to Request.URL. So, rather than modifying LLocation itself, it would probably work/make more sense to instead have PrepareRequest() preserve the existing IPVersion when processing ARequest.URL, eg:

procedure TIdCustomHTTP.PrepareRequest(ARequest: TIdHTTPRequest);
var
  LURI: TIdURI;
  ...
begin
  LURI := TIdURI.Create(ARequest.URL);

  try
    // Add this...?
    LURI.IPVersion := ARequest.IPVersion;
    // or maybe this?
    if ARequest.IPVersion = Id_IPv6 then begin
      LURI.IPVersion := Id_IPv6;
    end;

    ...
  finally
    FreeAndNil(LURI);  // Free URI Object
  end;
end;

@rlebeau rlebeau added Status: Review Needed Issue needs further review to decide next status and removed Status: Reported Issue has been reported for review labels Mar 17, 2024
@rlebeau
Copy link
Member

rlebeau commented Jul 16, 2024

Was my earlier suggestion helpful to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Element: HTTP Issues related to HTTP handling, TIdHTTP, TIdHTTPServer, TIdHTTPProxyServer, etc Status: Review Needed Issue needs further review to decide next status Type: Bug Issue is a bug in existing code
Projects
None yet
Development

No branches or pull requests

2 participants