Solved

Communication problem between CGI and browser

Posted on 1998-06-19
14
258 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:tplai
  • 5
  • 4
  • 2
  • +3
14 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829880
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
 

Author Comment

by:tplai
ID: 1829881
>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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829882
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
 

Author Comment

by:tplai
ID: 1829883
My CGI is written in C. In that case, you suggest to call fflush(stdout) at the end of my CGI ?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829884
Yes!

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829885
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
 

Author Comment

by:tplai
ID: 1829886
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 5

Expert Comment

by:julio011597
ID: 1829887
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
 

Author Comment

by:tplai
ID: 1829888
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829889
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
 
LVL 7

Accepted Solution

by:
jconde earned 200 total points
ID: 1829890
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
 

Expert Comment

by:waleed072098
ID: 1829891
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
 
LVL 1

Expert Comment

by:rcashon
ID: 1829892
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
 
LVL 1

Expert Comment

by:rcashon
ID: 1829893
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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to count occurrences of each item in an array.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now