Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

PHP content-length in header

Go to End



Community Member, 131 Posts

31 January 2011 at 12:28am

Edited: 31/01/2011 12:29am

Hi there

I'm creating a small iPhone application and to this I'm using a webservice powered by SilverStripe. I'm using a regular content controller for this in SilverStripe and I'm outputting some json after doing some database calls with DataObject::get. However the php response header are missing the "Content-length" parameter. This means that I cannot create a progressbar in my iPhone app, since I don't know the final length of the data responded from the url request.

If I copy the content and save this to a file I do have a length in my php header response. So my questions is, how can I get a "Content-length" parameter in a regular content controller output? Is this possible at all?

This is the output from my debugging consule in xCode (just to give you an idea of the problem):

Output when pointing to a content controller:

2011-01-30 11:49:53.304 ItalienskVinguide[38068:207] Headers: {
"Cache-Control" = "no-cache, max-age=0, must-revalidate";
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=\"utf-8\"";
Date = "Sun, 30 Jan 2011 10:49:52 GMT";
Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
"Keep-Alive" = "timeout=15, max=100";
Pragma = "no-cache";
Server = "Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch";
"Set-Cookie" = "PHPSESSID=69fb8561117b8164fd3663bd65ec539a; path=/";
"Transfer-Encoding" = Identity;
Vary = "Accept-Encoding";
"X-Powered-By" = "PHP/5.2.6-1+lenny8";

Output when pointing to a file with the same data, it's just a file on the server:

2011-01-30 12:20:49.088 ItalienskVinguide[38116:207] Headers: {
"Accept-Ranges" = bytes;
Connection = "Keep-Alive";
"Content-Length" = 732539;
"Content-Type" = "text/plain";
Date = "Sun, 30 Jan 2011 11:20:50 GMT";
Etag = "\"18ac0bd-b2d7b-49b0e7bd13c00\"";
"Keep-Alive" = "timeout=15, max=100";
"Last-Modified" = "Sun, 30 Jan 2011 11:20:16 GMT";
Server = "Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch";

Can anyone help me?