stephen/httplike — pull request #7 by stephank (2014-11-01 13:06:59+00:00)
Title: Fix UTF-8 data, and potential stalls.

The first commit may be the fix for https://github.com/stephen/airsonos/issues/38, but it's possible the reporters there are seeing a different issue.

The situation for me was that I tried to connect the default system audio output to AirSonos, which resulted in the failure popup, but also the following output on the console:

Received unknown RTSP method:

This was caused by the SETUP request. In the parsed request, the method was empty, and the request line actually ended up as the first header line. AirSonos then of course responds with 400.

Root cause was because my Mac is named "Stéphan's iMac", which is inserted in the `ANNOUNCE` right before the `SETUP`. This caused message splitting to break and the `SETUP` message to contain an extra newline at the start, which was actually part of the `ANNOUNCE` SDP.

The other commit is a fix for a theoretical stall, where a message stays unparsed in the buffer and is never emitted. (Not seen in practice.)

Tests pass.