Saturday, February 9, 2013

Debug the teapot - Enabling the 418 return code

I have found a simple a way to correct the lack of 418 return code.
There are php commands to control the return code in the header.

But to use it I first had to install PHP for my lighttpd server with this command:
"sudo apt-get install lighttpd php5-cgi"

After that I had to enable it in the server with these 2 commands
"sudo lighty-enable-mod fastcgi" "sudo lighty-enable-mod fastcgi-php"

After that I have renamed my index.html for index.php and then I have added this PHP code to my page.
"<?php
header("I'm a teapot!", true, 418);
?>"

Here is the result in the Firefox debuging console


2 comments:

  1. Wouldn’t it have been easier to either set lighthttpd to serve static files with headers precompiled into them as-is or to use its CGI support and write a shell script? I am a php user, but it seems overkill just to force an HTTP status code of 418.

    ReplyDelete
  2. Hi,
    Thank you for your comment,
    Yes, the PHP way isn't the most optimised, but it was the most easy way for me to find an quick solution.
    Your CGI option looks interresting, I'll explore it. But i'm not sure to understand what do you mean with "static files with headers precompiled".

    In fact, the 418 return code is just an step. I also need to find an solution to answer to BREW queries and not only GET and POST.

    ReplyDelete