Add transparent support for the tnetstring protocol
Similar to the python reference library. tnetstring parser from: https://github.com/jessedp/tnetstrings-php (with minor changes)
Tested with request_payloads.txt (from Mongrel2 Python tests)
Hold on, this may not be as simple as it looked... I've had to make other changes that I'm guessing would break the old protocol. I had to patch stuff like this in my code and in Request.php:
- if ($this->headers->METHOD == 'JSON') {
- return $this->data['type'] == 'disconnect';
+ if ($this->headers['METHOD'] == 'JSON') {
+ return ($this->data->type == 'disconnect');
If we wanted something really transparent we'd have to write some wrappers around it. In the long term I would try to aim at getting the JSON data parsed an array rather that using methods; what you you think?
The tests I've run checked that the data was parsed properly, not that is would be available using the same methods :(
Thanks
As expected the change pointed out was breaking JSON - so I made JSON return plain arrays as well and all if fine.
So both protocols have been tested - with a real handler, still haven't tried to get the unit tests to run - with GET's (with JSON being slightly faster as it decodes in C), I haven't tested POSTs yet.
Thanks