public function flushBuffer()
    {
        $this->expectedBodyLength = null;
        $this->headers = [];
        $this->mode = self::MODE_HEADER;

        $currentBuffer = substr($this->buffer, $this->offset);
        $this->offset = 0;
        $this->bufferSize = 0;
        $this->buffer = '';
        return $currentBuffer;
    }