protected function readUntil($search)
    {
        while (($position = strpos($this->buffer, $search)) === false) {
            if (feof($this->fp)) {
                fclose($this->fp);
                throw new DecodeException(
                    "Invalid multipart data encountered; " .
                    "end of content was reached before expected"
                );
            }
            $this->buffer .= fread($this->fp, $this->bytesPerRead);
        }
        return $position;
    }