Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » CGI-BIN bug with Apache Server
CGI-BIN bug with Apache Server [message #28225] Tue, 24 August 2010 09:14 Go to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hello everybody,

I experiment with CGI-BIN application into Apache Web Server and have a problem.

Here is my code

#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
   String ss = "";
   

   ss += "Content-type: text/html";
   ss += "<html><head><title>Hello!</title></head><body>";       
   ss += "Hi man! See my C++ CGI app?!";
   ss += "<h1>Good!</h1>";
   ss += "</body>";

   
   Cout() << ss;
}


The bug message is:

Quote:

500 Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, contact@domaine.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on the web site's server but the server could not be more specific on what the exact problem is.

-----------

I do the same code in Standard C :
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
   cout << "Content-type: text/html" << endl << endl << endl;

   cout << "<html><head><title>Hello!</title></head><body>" << endl
        << "Hi man! See my C++ CGI app?!" << endl
        << "<h1>Good!</h1>" << endl
        << "</body>";


  return 0;
}


It works!

What's wrong in u++ code???
Do the function Cout() is not correct?

I thank you for your response

ratah
Re: CGI-BIN bug with Apache Server [message #28226 is a reply to message #28225] Tue, 24 August 2010 09:59 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
It works!

I forgot to close html tag at the end!!

here is the correct code

#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
   String ss = "";
   

   ss += "Content-type: text/html";
   ss += "<html><head><title>Hello!</title></head><body>";       
   ss += "Hi man! See my C++ CGI app?!";
   ss += "<h1>Good!</h1>";
   ss += "</body></html>";

   
   Cout() << ss;
}

[Updated on: Tue, 24 August 2010 09:59]

Report message to a moderator

Re: CGI-BIN bug with Apache Server [message #28234 is a reply to message #28226] Tue, 24 August 2010 15:12 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
I did not test it, but "\r\n"s are missing:
ss += "Content-type: text/html\r\n\r\n";
Re: CGI-BIN bug with Apache Server [message #28236 is a reply to message #28234] Tue, 24 August 2010 15:56 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
zsolt> thanks for your precision,

Another questions about the CGI

- how do i do if i want to send an email smtp via my cgi?
- can i treat parameters like GET and POST as script languages (PHP, PERL,...) do

Thank you
Re: CGI-BIN bug with Apache Server [message #28240 is a reply to message #28236] Wed, 25 August 2010 05:55 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

ratah wrote on Tue, 24 August 2010 17:56

zsolt> thanks for your precision,

Another questions about the CGI

- how do i do if i want to send an email smtp via my cgi?
- can i treat parameters like GET and POST as script languages (PHP, PERL,...) do

Thank you

I had quite a good experience with U++ core binary as CGI for Apache. It works flawlessly for about 1,5 years at the moment.

Answers to your questions are:
1) There is SMTP-connected class described in Web/smtp.h
2) No, you can't. You should google what these parameters really are (usually - but not always,- it is a part of HTTP header). All you have in CGI are HTTP header + data and environment variables.
Re: CGI-BIN bug with Apache Server [message #28241 is a reply to message #28240] Wed, 25 August 2010 06:29 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
You could try to use the Web package instead of simple string concatenation. Classes like HtmlTag and Htmls are especially handy.


Regards,
Novo
Re: CGI-BIN bug with Apache Server [message #28258 is a reply to message #28241] Wed, 25 August 2010 11:28 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Many thanks,
I will give here an example when i finish to experiment.
Re: CGI-BIN bug with Apache Server [message #28280 is a reply to message #28240] Wed, 25 August 2010 16:35 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
Quote:

can i treat parameters like GET and POST as script languages (PHP, PERL,...) do


Check HttpQuery class.

You can see jeremy_c's ScgiServer class as an example.

Btw it is much better to use SCGI:
1. It is at least 100 times faster
2. You can easily debug your web app in the TheIde debugger

[Updated on: Wed, 25 August 2010 16:36]

Report message to a moderator

Re: CGI-BIN bug with Apache Server [message #28296 is a reply to message #28280] Thu, 26 August 2010 16:52 Go to previous message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
That's great!, but this needs lighttpd daemon which run under linux i suppose.
I work under windows, using apache.
I 'll try to find a windows version

Thanks
Previous Topic: MT again
Next Topic: Socket: SYN_SENT stalled when ipscan connections in CoWork (MT)
Goto Forum:
  


Current Time: Thu Mar 28 15:54:42 CET 2024

Total time taken to generate the page: 0.01506 seconds