Dear All,
I write a cgi program (coding in C) and run on apache2. (ver 2.2.x)
Now the client side get response data until the for loop end.
But I have to response data to client immediately instead of the CGI finished. 
What can I do for this issue ?

Note: I have already disabled the deflate.load in /etc/apache2/mods-enabled/

My CGI source code are below:
==================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <sys/ipc.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "cgivars.h"
#include <dirent.h>
#include <malloc.h>
#include <stdio_ext.h>

#define XML_RESPONSE_NO_EVENT \
"<Notification>"\
"<ServerStatus>"\
"<Timestamp>%s</Timestamp>"\
"<Type>xVRSvrMgrStatus</Type>"\
"<Content>"\
"<xVrSvrMgrStatus>-1</xVrSvrMgrStatus>"\
"</Content>"\
"</ServerStatus>"\
"</Notification>"


int handle_input_data(int form_method)
{
int i=0;
printf("HTTP/1.1 200 OK\n");
printf("Content-type: multipart/x-mixed-replace; boundary=xstringx\n"); 
printf("\n");
for(i=0;i<15;i++)
{
printf("--xstringx\n");
printf("Content-Type: text/xml; charset=utf-8\n"); 
printf("Content-Length: %d\n\n", strlen(XML_RESPONSE_NO_EVENT)); 
printf("\n%s", XML_RESPONSE_NO_EVENT);
printf("\n");
fflush(stdout);
sleep(1);
}
}
return 0;
}


int main(void)
{
int form_method; // POST = 1, GET = 0
form_method = getRequestMethod();
handle_input_data(form_method);
fflush(stdout);
exit(0);
}


Thanks & Best Regards,


Tai

Reply via email to