Page 1 of 1
testing CGI or FastCGI
Posted: Mon Aug 31, 2015 11:35 pm
by eddy
Hi,
How do you test CGI or FastCGI program ?
Re: testing CGI or FastCGI
Posted: Tue Sep 01, 2015 12:12 am
by Bisonte
Thats a good question. I install XAMPP to try this out. The original Perl CGI scripts are ok.
But how should i compile a PB CGI ?
all try's result in : Error 500 - Premature end of script headers
And by the way, the CGI example in the internal help (F1) is not avaible...
Re: testing CGI or FastCGI
Posted: Tue Sep 01, 2015 7:01 am
by infratec
Hi,
I compile it on linux, install it in an apache web content and test it with a web browser.
I always generate a logfile where I can put out informations.
I prefer SCGI over FastCGI.
It was faster and easier to handle.
http://www.purebasic.fr/english/viewtop ... 12&t=58776
Bernd
Re: testing CGI or FastCGI
Posted: Tue Sep 01, 2015 7:06 am
by Fred
To test CGI on Windows, I installed "easyphp"
http://www.easyphp.org/ , which install all needed tools, then added this to the apache conf file:
Code: Select all
ProxyPass /testfcgi/ fcgi://localhost:5600/
and uncommented the lines:
Code: Select all
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
Once restarted, apache should redirect the url
http://localhost/testfcgi to the port 5600
Then compile the example found in WaitFastCGIRequest() doc and it should work.
On linux, you need to do the same (installing apache and enabling mod proxy fastcgi)
Re: testing CGI or FastCGI
Posted: Tue Sep 01, 2015 10:12 am
by Kiffi
Bisonte wrote:all try's result in : Error 500 - Premature end of script headers
it seems, that
#PB_CGI_LastHeader doesn't work. So (at the moment) you have to add an extra line break by yourself.
doesn't work:
Code: Select all
If Not InitCGI() Or Not ReadCGI()
End
EndIf
WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html", #PB_CGI_LastHeader)
WriteCGIString("<html><title>PureBasic - test</title><body>" +
"Hello from PureBasic CGI<br>" +
"Actual time: <b>"+FormatDate("%hh:%ii", Date()) + "</b>" +
"</body></html>")
work:
Code: Select all
If Not InitCGI() Or Not ReadCGI()
End
EndIf
WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html", #PB_CGI_LastHeader)
WriteCGIString(#CRLF$) ; <-- !!!
WriteCGIString("<html><title>PureBasic - test</title><body>" +
"Hello from PureBasic CGI<br>" +
"Actual time: <b>"+FormatDate("%hh:%ii", Date()) + "</b>" +
"</body></html>")
Greetings ... Peter
Re: testing CGI or FastCGI
Posted: Tue Sep 01, 2015 10:13 am
by Fred
True, it's fixed, thanks.
Re: testing CGI or FastCGI
Posted: Thu Sep 24, 2015 2:46 pm
by dige
For use with Microsoft IIS, you need to check the ProgramParameter() first.
You'll get something like this: Port = 5600
Unfortunately, WaitFastCGIRequest() seems not work with IIS.
With ProcessExplorer running, I see that w3wp.exe (IIS) starts my fastcgi app,
but WaitFastCGIRequest() will not leaved..
Can someone help?