[FASTCGI] n00b question, fastcgi returning JSON

Luke Evans luke at eversosoft.com
Wed Aug 19 20:10:27 EDT 2009

OK, well I gave up on "application/json".
Google appears to serve JSON responses with "Content-type: text/ 
javascript; charset=ISO-8859-1\r\n" in the header, so I've gone for  

The header parser in the apache fastCGI module is clearly a particular  
kind of beast, and it chokes in a variety of ways that cause a n00b  
like myself to wonder what the heck is going on.  Also seemed to need  
to restart Apache at times, after errors, but the circumstances are  
lost in the fog of war.

Anyway, it seems that this all had very little to do with FastCGI per  

-- Luke

On 19-Aug-09, at 3:00 PM, Luke Evans wrote:

> Apologies in advance as I have a feeling this is a super 'duh'  
> question, and may only be obliquely related to fastcgi.  However...
> Having traversed the mires of getting my first FastCGI server built  
> and successfully hosted by Apache to return HTML, I thought I would  
> make a trivial change to the MIME type to have it return a JSON  
> string instead.
> Here's part of the code, patterned after the fastcgi C sample code:
> ...
> FCGX_FPrintF(out,
> 	//"Content-type: application/json\r\n"
> 	"Content-type: text/html\r\n"
> 	"\r\n"
> 	"%s",
> 	responseCString);
> ...
> Now, the code as it stands works fine, and my browser displays the  
> contents of "responseCString", which is some JSON text.
> However, if I comment out the second line, and uncomment the first  
> (to change the content type to befit the actual payload), I suddenly  
> get web errors logged:
> [Wed Aug 19 14:33:33 2009] [error] [client] FastCGI:  
> incomplete headers (32 bytes) received from server "/Library/ 
> WebServer/CGI-Executables/MyServer.fcgi"
> AFAICT the change to the header is correct and there's no change to  
> the overal structure of the response.  Yet this change is sufficient  
> to induce an error.
> It could be that I'm flying by the seat of my pants somehow with it  
> working in the text/html case, or perhaps application/json is  
> disallowed for some reason?
> Anyway, I'm sure there's a rather trivial reason for the failure and  
> I'm hoping that someone with even a little more experience in things  
> "web servery" will see the problem right away.
> Cheers
> -- Luke
> _______________________________________________
> FastCGI-developers mailing list
> FastCGI-developers at mailman.fastcgi.com
> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.pins.net/mailman/private.cgi/fastcgi-developers/attachments/20090819/2463e62f/attachment.html>

More information about the FastCGI-developers mailing list