Restructure response code parsing

This should be able to cope with multiple trailing newlines and async
codes in the same read as the actual response code better. At some
point, we should perhaps implement proper async response handling in a
more sensible way, though.