protected function _readStream() {
        if (!$this->debug_) {
            error_log('Intended as a debug-only function');
            return;
        }

        if (!is_resource($this->socket_)) {
            error_log("Invalid socket handle");
            return;
        }

        $buffer = "";
        $start = microtime(TRUE);
        while (!feof($this->socket_)) {
            $meta = stream_get_meta_data($this->socket_);
            error_log("socket status (". sprintf("%.2f", microtime(TRUE) - $start) . "s): ". json_encode($meta));

            $read = fread($this->socket_, 8192);
            if (strlen($read) == 0) {
                usleep(1e5);
            }
            $buffer .= $read;
        }
        $end = microtime(TRUE);
        error_log("Read took: " . ($end - $start) . " seconds.");

        $meta = stream_get_meta_data($this->socket_);
        $headers = array();
        foreach (explode("\n", $buffer) as $line) {
            $pair = explode(":", $line);
            if (count($pair) == 2) {
                $key = $pair[0];
                $value = $pair[1];
                $headers[$key] = $value;
            }
        }
        error_log("Response headers: " . json_encode($headers));
    }