[FASTCGI] Show image

Michael Borisov niro at tut.by
Mon Aug 11 02:40:49 EDT 2008


Hi All!
I try to show some image(png,jpg,gif) with fastcgi?

Simple CGI example works fine:

#include <fstream>
#include <stdio.h>
using namespace std;
int main(){    
   printf("Content-type: image/gif\r\n");
   printf("\r\n");
   ifstream in("../image.gif");
   if (!in) return 1;
   char buf;
   buf = in.get();
   while (in){
      printf("%c",buf);
      buf = in.get();
   }
   in.close();
   return 0;
}

FCGI example don't works:

#include <fstream>
#include "fcgi_stdio.h"
using namespace std;
int main(){
    while(FCGI_Accept() >= 0) {
        printf("Content-type: image/gif\r\n");
        printf("\r\n");
        ifstream in("../image.gif");
        if (!in) return 1;
        char buf;
        buf = in.get();
        while (in){
             printf("%c",buf);
             buf = in.get();
        } 
        in.close();
    }
    return 0;
}

What wrong with that code ? 
apache2                  2.2.3-4+etch4
libapache2-mod-fastcgi   2.4.2-8 
libfcgi0c2               2.4.0-6




More information about the FastCGI-developers mailing list