TIndySparkleHTTPServer gives incorrect port number

When using the Indy based server component of Sparkle and having SSL set-up I have noticed that requests using HTTPS will give an incorrect port number within THttpServerContext (C.Request.Uri.Port). A non-secure HTTP request will give a correct port number.
(Note: I am using localhost certificates)

To understand why this happened I inspected the source code and found the following:
C.Request.Uri.Port will be set based on a raw URI in TUri.ParseUri (unit Sparkle.Uri). When using an Indy based server this raw URI will be defined inside TIndyRequest.Create (unit Sparkle.Indy.Context) using a few TIdHTTPRequestInfo properties. One of these properties is the Host. Sparkle will use the host property to extract the port number, however when a HTTPS request is made the host property will not have a port number. 
HTTP on port 80  >  host property will be "localhost:80".
HTTPS on port 443 >  host property will be "localhost".

The Http.Sys-based server does not have this issue, that one works correctly.

To solve this issue I am using the following workaround to get the correct port number:

//workaround without having to change the source code
procedure TClass.Routine(const C: THttpServerContext);
	LIndyContext: TIndyContext;
	LMyPortNumber: Integer;

	if C is TIndyContext then begin
		LIndyContext := TIndyContext(C);
		LMyPortNumber := LIndyContext.ThreadContext.Binding.Port;

Is this a bug with the Indy based server?
Are there other or better workarounds for this issue?
Indeed, Sparkle is not detecting, when using Indy, if the connection is coming from http or https, which is causing confusion when detecting the default port (as for http the default port is 80).
We have modified the source code here to detect the https scheme which might solve your issue. Can you please contact us directly through e-mail to get this patch and see if it works for you?

Wagner R. Landgraf2019-07-23 18:37:52