Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » PHP content-length in header

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

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

Page: 1
Go to End
Author Topic: 1792 Views
  • joelg
    Community Member
    129 Posts

    PHP content-length in header Link to this post

    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?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.