Possible to use http.sys from a server built in Delphi?

Hi! I am working on converting some IntraWeb applications to http.sys, sharing the same port and SSL functionality. On the same servers as these web applications are running, we also have a couple of services that are RemObjects servers (currently using a TROIndyHttpServer component, and OpenSSL for the SSL functionality). Is it possible to make these services use http.sys instead, sharing the SSL port with the web applications, but accessed via e.g. mydomain.com/API/BIN or mydomain.com/API/JSON? I found I page that described a http.sys server component for .NET, but could not see any for Delphi (currently using RemObjects SDK 10.0.0.1469 in production). If there is no such Delphi server component, that would be a feature request from me :slight_smile:

Best regards

Magnus Oskarsson

1 Like

Hi,

use the TROWinHttpServer server.

Thanks for the quick reply Evgeny! Some follow up questions:

  1. Does this Delphi component correspond to HttpSysServerChannel for .NET?
  2. Can I set the port to the same as is used in other (web applications), and bind this server to e.g. /API/? 3. Do you use the Path property for this, and if so does RO handle the binding automatically?
  3. Do you have any documentation and/or code example I can look at?

Best regards

Magnus Oskarsson

Hi,

this Delphi server uses HTTP Server API - Win32 apps | Microsoft Docs .

yes, you can do this in OnManualBind event, like

procedure TForm3.ROWinHttpServer1ManualBind(Sender: TObject);
begin
  ROWinHttpServer1.Server.AddUrl('http://mydomain.com/API/BIN', fRegisterURL);
end;

by default, it uses:

    if fisHttps then
      s := id_https
    else
      s := id_http;
    fServer.AddUrl(Format('%s+:%d/%s',[s, Port, Path]));

usage of this server is similar to using other http servers, i.e. all of them are interchangeable.
one remark: it requires administrative rights for registering url.

if you need ssl support - this server can be configured with netsh or HttpSysManager utility.

Thanks Evgeny, I will do some tests as soon as I have time. I would prefer a solution where I specify only the relative path (like ‘/API/’) as it could be used on many different servers and url:s (we host some ourselves, but others are customer on-site systems). But if that is not possible I would have to add the base url in the app configuration (and force on-site customers to specify it).

Do I need to specify all the “path endings” (’/BIN’ etc.) also, or is that done automatically depending on which message components you have? (In the application I look at now, we have Bin, SOAP, and JSON running in parallel)

Best regards

Magnus Oskarsson

Hi,

You may use TROServerMultiMessage component. it can be registered to /API in server. other messages (bin, soap, json) should be added to SupportedMessages property.
clients can send bin/json/soap requests to /API - it will handle them correctly.

Hi again!

I tried using the TROServerMultiMessage component along with TROWinHttpServer but had all sorts of problems (I probably did not know how to configure it). But then I went back to basics get it working with just one message and empty path, then tested https, back to http and added non-empty path, added another message, etc. and alas, I seem to get it working without the MultiMessage component. And I did not make any custom bindings or anything, and did not specify the base url in any way. I have tested a setup with SSL where no path is my main web application, /m/ is a mobile friendly web application, and /api/json & /api/bin is the RO application, all at the same time with the same port 443.

Thanks for the help!

Hi,

have you tried such setup ?

Yes, I am pretty sure I did (without success). But as said, it seems I got it to work as desired without using this component. If/when we decide to make an implementation for production, I can let you know how it went.

Best regards

Magnus Oskarsson