ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
913 stars 376 forks source link

Fixes for firefox & another hidden bug #1

Closed torleif closed 12 years ago

torleif commented 12 years ago

You have to change line 153 in websockets.php to get it working firefox 11:

    //FIX for firefox (headers can contain keep-alive, Upgrade)
    if (!isset($headers['connection']) || strpos(strtolower($headers['connection']), 'upgrade') === FALSE) {

This is because firefox sends a keep-alive header as well.

There's also an issue with the extractHeaders() function, sometimes the header length will be extracted wrong. Causing it to over read the buffer and the frame will return an incorrect string. Right now sockets only accept UTF-8 so it will cause the connection to fail.

ghedipunk commented 12 years ago

Updated websockets.php for Firefox compatibility.

Researching extractHeaders() to support different character sets.

ghedipunk commented 12 years ago

Added in mb_strlen to deframe if the extension mbstring is available.

torleif commented 12 years ago

Just a side note, your server is fantastic. It's easy to use and extendable. Much better than the more popular srchea / PHP-Push-WebSocket which doesn't have proper thread support :)

I'll test it to see if using mb_strlen fixes the issue. I fixed the issue by calling utf8_encode on strings returned by the deframe() function, but that's a hack. I tested srchea against the same string input, and it fails this test as well.