Corsol Posted October 28, 2022 Share Posted October 28, 2022 Hi, i'm banging on a simple problem. On my windows 2019 server i've configured IIS for url rewrite to send request from my application to the local service unigui application builded in delphi. On Url Rewrite config, i've setted some custom server variables (like https://learn.microsoft.com/en-us/iis/web-dev-reference/server-variables) that i want to read on my application, but i don't know how to read it! Is there a way to read custom headers variables in http request from Server Module or Main Module or other component? Thanks Quote Link to comment Share on other sites More sharing options...
picyka Posted October 28, 2022 Share Posted October 28, 2022 3 minutes ago, Corsol said: Oi Estou batendo em um problema simples. No meu servidor windows 2019 eu configurei o IIS para reescrever url para enviar solicitação do meu aplicativo para o aplicativo unigui de serviço local construído em delfos. No Url Rewrite config, eu configurei algumas variáveis personalizadas do servidor (como https://learn.microsoft.com/en-us/iis/web-dev-reference/server-variables) que eu quero ler no meu aplicativo, mas eu não sei como lê-lo! Existe uma maneira de ler variáveis de cabeçalhos personalizados em http request do Server Module ou Main Module ou outro componente? Obrigado C:\Program Files (x86)\FMSoft\Framework\uniGUI\Demos\Desktop\URLParameters Quote Link to comment Share on other sites More sharing options...
Corsol Posted October 28, 2022 Author Share Posted October 28, 2022 Thanks for reply, but this is not what i need. I don't use the querystring parameter, but Server Variables of IIS. Inside Url Rewrite configuration of my web application, i can manage server variables as described here: https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#using-server-variables-in-rewrite-rules I need to read variable defined in this IIS Url Rewrite config from UniApplication. Thanks Quote Link to comment Share on other sites More sharing options...
MassimoD Posted November 4, 2022 Share Posted November 4, 2022 I push this question.... is there a way? Thanks. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted November 4, 2022 Share Posted November 4, 2022 1 hour ago, MassimoD said: I push this question.... is there a way? Thanks. Hi, is it possible to send some examples: did you use url parameters or do you use Headers and send "custom headers variables". Please explain in more detail. If You use simple URL parameters then You can read it by this way: UniMainModule.CommandLine.Values ['login'] On procedure TUniMainModule.UniGUIMainModuleHandleRequest, You can use this to read or replaceUniSession.ARequest.Referer := StringReplace (UniSession.ARequest.Referer, sRefererValues.Values['YourURLparams'],'YourValue',[]); If You send parameters in Headers, please send an example. Quote Link to comment Share on other sites More sharing options...
MassimoD Posted November 4, 2022 Share Posted November 4, 2022 Thanks for replay. No is not a parameter but header. As described here: https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#using-server-variables-in-rewrite-rules i've configured my IIS url rewrite to add a specific variable that is translated in a custom header in request to server. So i need to catch that specific header in my application. This is my url rewrite role in IIS. I've two server variables called "proprietario" and "edit" with a fixed value. I suppose that this two variables are translated in specific "proprietario" and "edit" additional header when IIS do the request to local unigui application. How to retrive this two header? With dev tool of chrome or firefox i can't see them because is not the browser that add those header but IIS after rewrite to unigui. Thanks Quote Link to comment Share on other sites More sharing options...
irigsoft Posted November 5, 2022 Share Posted November 5, 2022 7 hours ago, MassimoD said: Thanks for replay. No is not a parameter but header. As described here: https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#using-server-variables-in-rewrite-rules i've configured my IIS url rewrite to add a specific variable that is translated in a custom header in request to server. So i need to catch that specific header in my application. This is my url rewrite role in IIS. I've two server variables called "proprietario" and "edit" with a fixed value. I suppose that this two variables are translated in specific "proprietario" and "edit" additional header when IIS do the request to local unigui application. How to retrive this two header? With dev tool of chrome or firefox i can't see them because is not the browser that add those header but IIS after rewrite to unigui. Thanks did You try to read headers in UniGUIServerModuleHTTPCommand, ARequestInfo.RawHeaders.Text ARequestInfo.RawHTTPCommand ARequestInfo.CustomHeaders and search for: "For example, in order to access the HTTP header "user-agent" from a rewrite rule, you can use the {HTTP_USER_AGENT} server variable." 1 Quote Link to comment Share on other sites More sharing options...
MassimoD Posted November 5, 2022 Share Posted November 5, 2022 yes... but none of my variables are present... here my output ARequestInfo.RawHeaders.Text --> Debug Output: Connection: Keep-Alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.5 Host: localhost:8077 Max-Forwards: 10 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0 Upgrade-Insecure-Requests: 1 X-Original-URL: / X-Forwarded-For: 127.0.0.1:49923 X-ARR-LOG-ID: e5a44ee3-4df5-4891-9db4-238fcd65d1f5 Process URLParamsDemo.exe (9860) ARequestInfo.RawHTTPCommand --> Debug Output: GET / HTTP/1.1 Process URLParamsDemo.exe (9860) ARequestInfo.CustomHeaders--> Debug Output: ?m Process URLParamsDemo.exe (9860) I'm considering to wrong configuration in url rewrite rule...... or not? My action role is: Quote Link to comment Share on other sites More sharing options...
irigsoft Posted November 5, 2022 Share Posted November 5, 2022 19 minutes ago, MassimoD said: yes... but none of my variables are present... here my output ARequestInfo.RawHeaders.Text --> Debug Output: Connection: Keep-Alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.5 Host: localhost:8077 Max-Forwards: 10 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0 Upgrade-Insecure-Requests: 1 X-Original-URL: / X-Forwarded-For: 127.0.0.1:49923 X-ARR-LOG-ID: e5a44ee3-4df5-4891-9db4-238fcd65d1f5 Process URLParamsDemo.exe (9860) ARequestInfo.RawHTTPCommand --> Debug Output: GET / HTTP/1.1 Process URLParamsDemo.exe (9860) ARequestInfo.CustomHeaders--> Debug Output: ?m Process URLParamsDemo.exe (9860) I'm considering to wrong configuration in url rewrite rule...... or not? My action role is: Sorry but I can't help with IIS, based on the last image I think you will get the value of {R:2} in the unigui UniMainModule.CommandLine.Values ['YOURParamNAME']. Have you tried it? Quote Link to comment Share on other sites More sharing options...
MassimoD Posted November 5, 2022 Share Posted November 5, 2022 oh god..... found the mistake............. the name of server variable... it NEED to be prefixed with HTTP_ With this change i catch it on RawHeaders. ARequestInfo.RawHeaders.Text --> Debug Output: Connection: Keep-Alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.5 Host: localhost:8077 Max-Forwards: 10 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0 Upgrade-Insecure-Requests: 1 PROPRIETARIO: audiosales X-Original-URL: / X-Forwarded-For: 127.0.0.1:50245 X-ARR-LOG-ID: 55a3404b-6d6d-41c1-a3f9-614d7152fcd8 Process URLParamsDemo.exe (6844) Btw i'll check also if is available in UniMainModule.CommandLine.Values Many thanks! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.