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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Call to undefined method HttpResponse::setBody()


Go to End


5 Posts   1926 Views

Avatar
zealiod

Community Member, 5 Posts

1 September 2008 at 10:16pm

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

Avatar
grilldan

Community Member, 135 Posts

1 September 2008 at 10:54pm

Edited: 01/09/2008 10:55pm

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('/>','xml:lang','application/xhtml+xml'),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" xml:lang="en" lang="en">

Avatar
zealiod

Community Member, 5 Posts

2 September 2008 at 2:21am

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

Avatar
zealiod

Community Member, 5 Posts

2 September 2008 at 4:17am

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?

Avatar
zealiod

Community Member, 5 Posts

2 September 2008 at 6:42am

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