Month: November 2009

HTTP headers and raw POST data for PHP-CGI

I host my website on Dreamhost and as good value as it is, with great email/SVN/MySQL and hosting, there are some limitations. One of them is trying to read raw POST data from $HTTP_RAW_POST_DATA and the other is trying to read custom HTTP headers because PHP runs as a CGI module using there service.

I realised the working around for getting raw post data is to use:

$data = file_get_contents(‘php://input’);

And that you can use mod_rewrite to to pass HTTP headers to the $_SERVER variable, as described here. If you want to add additional header values, you must specify each one as a seperate E= statement in your .htaccess file. I was writing a CALDAV server and wanted to be able to (1) use the HTTP authentication described here, (2) read the “Depth” HTTP header, and (3) redirect all requests queries through a single php file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [E=REDIRECT_REMOTE_USER:%{HTTP:Authorization},E=DEPTH:%{HTTP:Depth},L]
RewriteRule .* – [E=REDIRECT_REMOTE_USER:%{HTTP:Authorization},E=DEPTH:%{HTTP:Depth},L] RSS Smart Mailbox

If like me you have quite a lot of RSS subscriptions within Apple you may find that you either get sick of navigating each RSS folder on the left individually but don’t want to put all your RSS subscriptions within your inbox. What I realised you could do is create a smart mailbox to only show read RSS items, greatly saving space in the left hand pane, and making it easy to navigate all unread subscriptions.

iSync icon after iTunes sync

For some of you this maybe so minor its not worth worrying about, but I really don’t like how if conflict resolver is shown when syncing my iPhone with iTunes, the iSync icon gets added to my menu bar no matter whether I click sync now or later after resolving the conflict. I’ve contacted Apple about this, but I recently found this article ( that helps explain how to load menu items. What I’ve done instead is rename the sync menu item, so that it never gets loaded. Quick disclaimer, I’m not responsible for any damage to your computer using this command.

sudo mv “/System/Library/CoreServices/Menu Extras/” “/System/Library/CoreServices/Menu Extras/”