[FASTCGI] n00b question, fastcgi returning JSON

Luke Evans luke at eversosoft.com
Wed Aug 19 18:00:51 EDT 2009


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 192.168.1.5] 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



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


More information about the FastCGI-developers mailing list