testing CGI or FastCGI

Just starting out? Need help? Post your questions and find answers here.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

testing CGI or FastCGI

Post by eddy »

Hi,

How do you test CGI or FastCGI program ?
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
Bisonte
Addict
Addict
Posts: 1310
Joined: Tue Oct 09, 2007 2:15 am

Re: testing CGI or FastCGI

Post 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...
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
infratec
Always Here
Always Here
Posts: 7598
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: testing CGI or FastCGI

Post 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
Last edited by infratec on Tue Sep 01, 2015 7:08 am, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18167
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: testing CGI or FastCGI

Post 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)
User avatar
Kiffi
Addict
Addict
Posts: 1492
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: testing CGI or FastCGI

Post 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
Hygge
Fred
Administrator
Administrator
Posts: 18167
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: testing CGI or FastCGI

Post by Fred »

True, it's fixed, thanks.
dige
Addict
Addict
Posts: 1396
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: testing CGI or FastCGI

Post 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?
"Daddy, I'll run faster, then it is not so far..."
Post Reply