RTC Forums
May 17, 2024, 09:02:32 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: rtcFileProvider not serving up pages?  (Read 4095 times)
brian71us
RTC Expired
*
Posts: 15


« on: October 11, 2017, 01:30:16 AM »

Hello,

I pilfered the rtcFileProvider data module from the RTCWebServer demo for my own project. It is a Delphi back end with a TWebBrowser that needs to display web pages served up via a TRtcHttpServer. The web page will then use XMLRPC to talk to the Dephi application behind it.

I've modified the DataModuleCreate constructor as follows:

  folder := 'c:\inetpub\wwwroot\';

  filename := System.IOUtils.TPath.Combine(folder, 'index.html');

  AddContentType('c,pas,asc,txt,ini=text/plain');
  AddContentType('html,htm=text/html');
  ... etc ...

  AddIndexPage(filename);
  AddHost('localhost:8096=' + folder);

The application builds and runs but the web page doesn't show up in the embedded web browser.

When I type this into a web browser...

http://localhost:8096/index.html

I get the text below and the browser just keeps spinning.

Your IP: 127.0.0.1
Server Time: 8:29:37 PM
Connection count: 4
Memory in use: 273.531 MB
Logged
Star5
RTC Expired
*
Posts: 27


« Reply #1 on: October 11, 2017, 01:48:24 AM »

AddHost('*=.\www');
AddIndexPage('index.htm');
AddContentType('c,pas,asc,txt,ini=text/plain');
...
rtcFileProvider.GetFileProvider.ServerLink.Server := RtcHttpServer1;
RtcHttpServer1.ServerPort:='8833';
RtcHttpServer1.Listen(False);

Host writing '*=.\www' or '*=c:\www' or '/up=.\upload'
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: October 11, 2017, 09:17:06 AM »

1. If you are using an older RTC SDK version, the response you are getting could be from the "TimeProvider" component on the "TFile_Provider" module implemented in the "rtcFileProvider" unit, but ... it could also be from one of your other TRtcDataProvider instances, or your default response to all requests which weren't accepted.

2. The "AddHost" method uses '*' to match all HOST names (ignore the HOST entry). Otherwise, it needs the exact HOST header received from the Browser. For local tests and all Servers hosting one domain, using '*' for the Host should be enough. For example, AddHost('*=c:\inetpub\www') would make all "other" hosts (those not explicitly added with a host name) use the 'c:\inetpub\www' folder as their root.

3. The "AddIndexPage" method expects a File name with a relative path, but you are providing your index file with the absolute path (including drive and full folder path), which might be a reason for the file NOT being found. For example, AddIndexPage('index.html') should work if you place the 'index.html' file into the root folder you've set up with the "AddHost" method (see point 2 above).

In short, if you place all the files you want to make accessible into the "c:\inetpub\wwwroot" folder (including your "index.html" file) and sub-folders, using this set of parameters should do the trick ...

 AddIndexPage('index.html'); // required
 AddHost('*=c:\inetpub\wwwroot'); // required
 AddContentType('html,htm=text/html'); // recommended
 AddContentType('c,pas,asc,txt,ini=text/plain'); // optional

PS. I guess, you have assigned your TRtcHttpServer instance to the "ServerLink.Server" property on the "File_Provider" DataModule, as pointer out by Star5 in his reply (see above).

Best Regards,
Danijel Tkalcec
Logged
brian71us
RTC Expired
*
Posts: 15


« Reply #3 on: October 12, 2017, 02:40:20 PM »


I corrected my index page and host and it's working now.  Grin

Thanks, guys!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 15 queries.