Communication problem between CGI and browser

Client : Nestcape Navigator or Nescape Communicator or MSIE 3
Server : Netscape Enterprise Server

When I submit a form, calling my CGI, my client doesn't understand the ending of this CGI. So, the client is still looping, even when the end of the CGI is reached. The CGI accesses a database, and then sends an HTML page to the client, with a Location. Sometimes, when the processing of the CGI is fast, there is no problem and the HTML page is correctly displayed.

On the server side, in all cases, the response is correct (for instance : ... "GET myCGI ... HTTP/1.0" 200 847, where 847 is the size (in bytes) of the HTML page.

Thierry PLAI - FRANCE
tplaiAsked:
Who is Participating?
 
jcondeConnect With a Mentor Commented:
Hi!

First check there's no infinite loops after the form is submited!
Try erasing the METHOD=POST/GET from your html code.
Are you making a plus to space conversion when after you read the QUERY_STRING?
Are you unescaping the QUERY_STRING correctly?

If you're interested, please send me a copy of the code so i can check it out!

bye
jorge
0
 
Michel PlungjanIT ExpertCommented:
Do you flush the server cache in the cgi?
Do you have a linefeed after the last line of html
Is that last line </HTML>

If the cgi only gives a location do you have the extra linefeed after the last http-header?

Michel
0
 
tplaiAuthor Commented:
>Do you flush the server cache in the cgi ?
How can I do this ?

>Do you have a linefeed after the last line of html ?
Yes.

>Is that last line </HTML> ?
Yes.

>If the cgi only gives a location do you have the extra linefeed after the last http-header ?
Yes. Sometimes, that works !
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Michel PlungjanIT ExpertCommented:
In perl:

 $| = 1;

From the perl faq:

autoflush HANDLE EXPR
$OUTPUT_AUTOFLUSH
$|
     If set to nonzero, forces a flush after every write or print on the currently selected output channel. Default is 0 (regardless
     of whether the channel is actually buffered by the system or not; $| tells you only whether you've asked Perl explicitly to
     flush after each write). Note that STDOUT will typically be line buffered if output is to the terminal and block buffered
     otherwise. Setting this variable is useful primarily when you are outputting to a pipe, such as when you are running a Perl
     script under rsh and want to see the output as it's happening. This has no effect on input buffering. (Mnemonic: when you
     want your pipes to be piping hot.)

Michel
0
 
tplaiAuthor Commented:
My CGI is written in C. In that case, you suggest to call fflush(stdout) at the end of my CGI ?
0
 
Michel PlungjanIT ExpertCommented:
Yes!

Michel
0
 
Michel PlungjanIT ExpertCommented:
and even in the middle too if it takes long to format the data (only works from the time you start outputting HTML)

Michel
0
 
tplaiAuthor Commented:
Without fflush, the server processes correctly my CGI. In the log server file, the size of the HTML page I want to disply is correct (... "GET myCGI ... HTTP/1.0" 200 847, where 847 is the size (in bytes) of the HTML page).
0
 
julio011597Commented:
The web server logging the access should tell the connection has succesfully completed (well, unless i'm wrong), so the problem should be on the client side - that is, i'd also investigate the HTML output.

Can you show the HTML output you are sending, or better yet is your cgi online to test it?
Also, the client hangs at the end of the page? In the middle? What source can you see after hitting stop?

-julio
0
 
tplaiAuthor Commented:
The HTML output is correct and I can show it. I have transferred my CGI on an other computer with more memory and it seems working correctly. I think this problem is due to less resources on the first computer.
0
 
Michel PlungjanIT ExpertCommented:
So you answered your own question: Sometimes, when the processing of the CGI is fast, there is no problem and the HTML page is correctly displayed.

Glad to hear it works

Michel

PS: Flushing stdout for 847 bytes is a bit overkill anyway ;-) I work more in 100KB+


0
 
waleed072098Commented:
I just install a MIIS 3 server in my NT machine. When I click on the button to execute a cgi script from the Web page, the browser opens the script as a text file or open the save as window. I tried everything :
-Permission (full access granted)
-Run the program in the command line. (it runs w/o problems) .
-Run the same program in a UNIX web server (it runs w/o problems).
Can you help please.

Wal
0
 
rcashonCommented:
tplai, I had a similiar problem on executing my CGI's in C and mplungjan solved my problem in that my CGI's were not terminating correctly. The problem was that I was not compiling in a 32 bit compiler I was using 16 bit. This is just a footnote for you because I lost alot of hair and sleep till mplugjan helped me resolve it....
Randall

0
 
rcashonCommented:
waleed,
 Two things: First I would assume you meant to post this as your own question not as a comment for tplai, and second a possible solution as to why your CGI is not working correctly would be to check case sensitivity of your executable name. I have been caught a couple of times when a file is edited of it changing the capitalization of the file name. If that happens depending on your how your CGI is returning the page can cause it to open in a window. Check that out and let me know . Hope this helps...

Randall
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.