Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Call to undefined method HttpResponse::setBody()

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1306 Views
  • zealiod
    Avatar
    Community Member
    5 Posts

    Call to undefined method HttpResponse::setBody() Link to this post

    After installation I get this error msg when browsing my new site...
    What does it mean and how can I fix it?

    Fatal error: Call to undefined method HttpResponse::setBody() in /home/wales4je/public_html/sapphire/core/control/ContentNegotiator.php on line 104

    Regards,

    Z

  • grilldan
    Avatar
    Community Member
    135 Posts

    Re: Call to undefined method HttpResponse::setBody() Link to this post

    I looked at the function, and I think it might have something to do with your template. (or I am way off =)

       function html(HTTPResponse $response) {
          $response->addHeader("Content-type", "text/html; charset=" . self::$encoding);
          $response->addHeader("Vary", "Accept");

          $content = $response->getBody();

          $content = ereg_replace("<\\?xml[^>]+\\?>\n?",'',$content);
          $content = str_replace(array('/>','lang','text/html'),array('>','lang','text/html'), $content);
          $content = ereg_replace('<!DOCTYPE[^>]+>', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', $content);
          $content = ereg_replace('<html xmlns="[^"]+"','<html ', $content);
          
          $response->setBody($content);
       }

    What are the first 2 lines of your yourtheme/templates/Page.ss?

    Try adding this.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" lang="en">

  • zealiod
    Avatar
    Community Member
    5 Posts

    Re: Call to undefined method HttpResponse::setBody() Link to this post

    As suggested, I have made sure that all the .ss files begin with the html stated - they now all do. However, on trying to flush the cache using ?flush=1, I still get the same error, and i'm unsure if the flush did infact work...

    thanks,

    Z

  • zealiod
    Avatar
    Community Member
    5 Posts

    Re: Call to undefined method HttpResponse::setBody() Link to this post

    The error has now changed (i reuploaded the negociator file, to make sure it was clean)...
    I now get...

    Fatal error: Call to undefined method HttpResponse::addHeader() in /home/wales4je/public_html/sapphire/core/control/ContentNegotiator.php on line 95

    Same function - different line??

    Any ideas?

  • zealiod
    Avatar
    Community Member
    5 Posts

    Re: Call to undefined method HttpResponse::setBody() Link to this post

    I never fixed this - so am going for a fresh install.... thanks everyone.

    1306 Views
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.