Jump to content

Intercept URI


Max3073

Recommended Posts

Hello!
I would like to make a UniGUI Application that can show a specific form according to the URL.

I don't want to use parameters I need to use specific URIs

Example: 

http://localhost:8077/hello must show a form with some content

Unfortunately using a URL other than http://localhost:8077 results in "Invalid session or session Timeout. (Invalid URI: /hello )"

Is there a solution?

Thank you.

 

 

 

Link to comment
Share on other sites

  • 1 month later...

An alternative is to insert "?" before the various URI's (e.g. http://localhost:8077/?hello)
Then in ServerModule you can do:

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);

begin
  if (ARequestInfo.Command = 'GET') and (ARequestInfo.URI = '/') and (ARequestInfo.QueryParams)>"")then
  begin
    //Here you can store the URI into a global variable in ServerModule that you can interrogate in the resulting session
    // e.g. LoginURI := ARequestInfo.QueryParams
    // this stores the URI without the "?"    
  end;

 

  • Thanks 1
Link to comment
Share on other sites

I guess you can solve this using hyperserver and aliases in the web server setup, running two separate instances of the app, one in each directory:

<Directory "C:/myapp1>
    Options FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    DirectoryIndex myapp.dll?q=param1
</Directory>
Alias /option1 "C:/myapp1"

<Directory "C:/myapp2>
    Options FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    DirectoryIndex myapp.dll?q=param2
</Directory>
Alias /option2 "C:/myapp2"                                      

So the URL would be https//mydomain.com/option1 or 2, as the dll is specified as the folder index.

You may skip using a parameter, by just checking startup directory to determine which alias was used.

Using a URL Rewrite function in the web server setup is another option, to translate part of a URL to a parameter.

Link to comment
Share on other sites

I see, then you could probably use a simple proxy server with only url rewriting capabilities, like EZProxy:

https://help.oclc.org/Library_Management/EZproxy/Get_started/About_URL_rewriting

Edit: I did not notice that EZProxy costs money, but there are probably other free proxy servers out there, or you could even build your own using Indy components.

It is basically two http servers and two clients, feeding data from each server to each client in a cross pattern, being on different ports or IPs.*
And then just add a url rewrite function, to convert the last part of the url to a parameter format.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...