It is currently Sun Oct 25, 2020 3:42 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: testing CGI or FastCGI
PostPosted: Mon Aug 31, 2015 11:35 pm 
Offline
Addict
Addict
User avatar

Joined: Mon May 26, 2003 3:07 pm
Posts: 1477
Location: Nantes
Hi,

How do you test CGI or FastCGI program ?

_________________
Imagewin8.1 x64 5.31 | IDE | PB plugin | Tools | Sprite | JSON | visual tool


Top
 Profile  
Reply with quote  
 Post subject: Re: testing CGI or FastCGI
PostPosted: Tue Sep 01, 2015 12:12 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1140
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 5.72 LTS (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 64GB RAM | iChill GeForce RTX 2080 Super | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: testing CGI or FastCGI
PostPosted: Tue Sep 01, 2015 7:01 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4980
Location: Germany
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.

viewtopic.php?f=12&t=58776

Bernd


Last edited by infratec on Tue Sep 01, 2015 7:08 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: testing CGI or FastCGI
PostPosted: Tue Sep 01, 2015 7:06 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14116
Location: France
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:
ProxyPass /testfcgi/ fcgi://localhost:5600/


and uncommented the lines:

Code:
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)


Top
 Profile  
Reply with quote  
 Post subject: Re: testing CGI or FastCGI
PostPosted: Tue Sep 01, 2015 10:12 am 
Offline
Addict
Addict
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 1148
Location: Amphibios 9
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:
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: testing CGI or FastCGI
PostPosted: Tue Sep 01, 2015 10:13 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14116
Location: France
True, it's fixed, thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: testing CGI or FastCGI
PostPosted: Thu Sep 24, 2015 2:46 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Apr 30, 2003 8:15 am
Posts: 1048
Location: Germany
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..."


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye