tags:

views:

29

answers:

2

I would like to return an error code on accessing a page, specifically a 418 error to see how my browser/server will implement it (and in case I ever manage to wire the appropriate devices to my digital coffee/tea pot I would like to know when it's done :) )

Is this even supported on Apache/2.2.14 (Ubuntu)?

+3  A: 

You can make a simple PHP page that sends the appropriate header.

<?php header("HTTP/1.1 418 I'm a teapot"); exit; ?>

However, it's simply going to do nothing. As much as all other 4xx status codes don't alter the page's behavior, this one will also just display the rest of the content you've sent.

zneak
sorry, wouldn't format for a comment, so it's in a reply.
EricR
A: 

Interestingly enough, it fails to send the rest of the data.

GET http://***/index.php
User-Agent: lwp-request/5.834 libwww-perl/5.834

GET http://***/index.php --> 418 I'm a teapot
Connection: close
Date: Tue, 13 Jul 2010 17:25:46 GMT
Server: Apache/2.2.14 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html
Client-Date: Tue, 13 Jul 2010 17:25:46 GMT
Client-Peer: 127.0.1.1:80
Client-Response-Num: 1
X-Powered-By: PHP/5.3.2-1ubuntu4.2
EricR
Edit your question next time you have to submit updates :) Answers are not the right place. That being said, if you keep the `exit;` at the end of my code, the script will stop right there instead of sending the rest.
zneak
Cheers mate. Much appreciated.
EricR