![]() |
Using CGI exe with IW - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Using CGI exe with IW (/thread-1224.html) |
Using CGI exe with IW - cprmlao@hotmail.com - 09-08-2019 Hi, I have a cgi exe of a third party that I need using to use with IW. It works well using apache, IIS, AppServer ...... But I want to use IW. The cgi.exe is named dgate.exe. I did all setup after read the docs of cgi to use with a webserver. It said just to copy a folder called cgi-bin to wwwroot of the webserver. To test I have to use: http://127.0.0.1:8888/cgi-bin/newweb/dgate.exe?mode=top I did a test using a button click that run this code: Code: procedure TIWUserSession.load_dicom(); Here is the lua script executed by "dgate.exe" cgi to produce the html output: Code: HTML("Content-type: text/html\nCache-Control: no-cache\n"); The cgi generate a html page on the fly using your internal code with lua script. I can´t change that lua script from cgi. How could I take the html page generated by dgate.exe to put after "if CGIRunner.StatusResult = 0 then" and show in the browser? RE: Using CGI exe with IW - Alexandre Machado - 09-09-2019 TIWCGIRunner.ResponseHeaders and TIWCGIRunner.ResponseContent both contain whatever the CGI script generated, i.e. headers and content. In general you don't need the headers (unless there is something very specific on it, but it is not common). You can just take the ResponseContent and write as is to the IW Response like: if CGIRunner.StatusResult = 0 then begin WebApplication.Response.WriteString(IWCGIRunner.ResponseContent.Text); end; It will work as long as your ResponseContent contains a correct representation of a valid HTML page RE: Using CGI exe with IW - cprmlao@hotmail.com - 09-10-2019 Hi, Alexandre, In the code posted above, I just did a test using: Code: WebApplication.Response.WriteString('<html><head></head><body>test</body></html>'); but I get an error: Code: Exception message : Reply type already set. RE: Using CGI exe with IW - Alexandre Machado - 09-10-2019 Hum... looks like you need to reset the request. Try this: with WebApplication.Response do begin ResetReplyType; Code := 200; ContentType := MIME_HTML; WriteString(Your html here); end; It should work RE: Using CGI exe with IW - cprmlao@hotmail.com - 09-10-2019 (09-10-2019, 09:27 AM)Alexandre Machado Wrote: Hum... looks like you need to reset the request. Try this:Hi, Alexandre, It doesn't work. I have the same problem. Luik RE: Using CGI exe with IW - cprmlao@hotmail.com - 09-10-2019 Another problem is that the cgi is returning nothing: If I do: Code: C:\AppProg\GestanCloud\wwwroot\cgi-bin\newweb>dgate But if I do: Code: C:\AppProg\GestanCloud\wwwroot\cgi-bin\newweb>set QUERY_STRING=hallo It looks like intraweb does not set QUERY_STRING or maybe it runs dgate.exe in the incorrect folder. RE: Using CGI exe with IW - Alexandre Machado - 09-10-2019 That's not how CGI are supposed to work. CGI applications obtain all parameters from environment variables and IntraWeb executes the CGI application and communicates with it via named pipes. Query_string is correctly set before executing the CGI script and all content returned by the script is put into ResponseContent property. RE: Using CGI exe with IW - Alexandre Machado - 09-10-2019 What I think you must have in mind is that query_string might be empty. The query_string of a request to a IW application may or may not have data. Are you using a sync or async request? What is the expected input for that CGI script? RE: Using CGI exe with IW - cprmlao@hotmail.com - 09-10-2019 Hi , Alexandre. There is no other requirement. The cgi must be called using http://127.0.0.1:8888/cgi-bin/newweb/dgate.exe?mode=top. Just It. It runs ok in wamp server and appserver. And I have only to copy the cgi-bin folder with the cgi to wwwroot. I have contacted the author and He said the problem is with the www server. This cgi is part of a opensource project of pacs dicom server and is used for many people in the world. It is part of Conquest dicom server(https://ingenium.home.xs4all.nl/dicom.html). (09-10-2019, 09:03 PM)Alexandre Machado Wrote: What I think you must have in mind is that query_string might be empty. The query_string of a request to a IW application may or may not have data. Are you using a sync or async request? What is the expected input for that CGI script?I am using sync request. It must return something as: Content-type: text/html Cache-Control: no-cache <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Conquest DICOM server - version 1.4.19</TITLE> <style type="text/css"> body { font:10pt Verdana; } a { color:blue; } #content { background-color:#dddddd; width:200px; margin-top:2px; } h1 {background-color:#6495ed;} </style> </HEAD> <BODY BGCOLOR='CFDFCF'> <H1>Welcome to Conquest DICOM server - version 1.4.19</H1> RE: Using CGI exe with IW - Alexandre Machado - 09-12-2019 If it requires the query_string to be mode=top, then you need to make sure it is before calling it. You will need to modify the query_string yourself and make sure it matches the spec. You are free to alter Request.QueryFields. It is just a TStringList which can be cleared and filled by you, before calling the CGIRunner |