| | |
| | | $mode = 0; |
| | | } |
| | | |
| | | // Use BINARY extension when possible (and safe) |
| | | $binary = $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY'); |
| | | $fetch_mode = $binary ? 'BINARY' : 'BODY'; |
| | | |
| | | // format request |
| | | $reply_key = '* ' . $id; |
| | | $key = $this->nextTag(); |
| | | $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id (BODY.PEEK[$part])"; |
| | | $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part])"; |
| | | |
| | | // send request |
| | | if (!$this->putLine($request)) { |
| | | $this->setError(self::ERROR_COMMAND, "Unable to send command: $request"); |
| | | return false; |
| | | } |
| | | |
| | | if ($binary) { |
| | | $mode = -1; |
| | | } |
| | | |
| | | // receive reply line |
| | |
| | | $prev = ''; |
| | | |
| | | while ($bytes > 0) { |
| | | $line = $this->readLine(4096); |
| | | $line = $this->readLine(8192); |
| | | |
| | | if ($line === NULL) { |
| | | break; |