Programming - - By Harry Fuecks

PHP Atom Server

While out hunting for someone who’s implemented some kind of timeout mechanism when using XMLHttpReqeust, ran into isolani’s PHP Atom Server (serves ATOM XML), which I guess is part of the isoTope framework he’s working on, as well as a Javascript ATOM client (which uses XMLHttpRequest).

Interested to see he’s using the php://input stream. In fact there is another way to access the raw POST data in PHP, which will work on older PHP versions, using the global variable $HTTP_RAW_POST_DATA. Unless you have always_populate_raw_post_data switched on in php.ini, this global only exists if an HTTP POST was made without a Content-Type of “application/x-www-form-urlencoded” (which is the default content type for a normal form). Believe you also need to declare it or access it via the $GLOBALS array, unlike other variables such as $_GET and $_SERVER e.g.;

function getRawPost() {

// or

Doesn’t bring me any closer to implementing timeouts with XmlHttpRequest though ;) Got some wierd stuff happening now – IE calls the XmlHttpRequest.onreadystatechange callback both for sync and async requests but if you call the abort() method, prepare to kill -9 (the Windows way). Meanwhile Mozilla seems to ignore onreadystatechange completely, when making sync requests, which doesn’t leave much room for a timeout.

Some other interesting links along the way;

Cross-Browser XMLHttpRequest – provides a partial XMLHttpRequest implementation for Opera

libXmlRequest – very interesting implementation, using a pool of XMLHttpRequest objects. But still doesn’t seem to answer the timeout mystery.

Also from the libXmlRequest author: engine for web applications – something in the same ball park as ScriptServer. Personally turned me off with “too many” layers of abstration and excessive XML but perhaps that’s me – transparency is relative.

Looking in all the wrong places! Christian has the answer with Livesearch – use Window.setTimeout()