summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap_generic.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-10-25 07:45:35 +0000
committeralecpl <alec@alec.pl>2010-10-25 07:45:35 +0000
commit781f0ca54c4fe123366dc563a253658382541525 (patch)
treea4be66a507df7784b75d917e51b86cf34867628d /program/include/rcube_imap_generic.php
parent80bc55e0dc088d94720271b95e19778bd72bd3c7 (diff)
- Improve performance by reading optional capability response from AUTHENTICATE
Diffstat (limited to 'program/include/rcube_imap_generic.php')
-rw-r--r--program/include/rcube_imap_generic.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 62a3d8280..8df2a2ed7 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -119,6 +119,7 @@ class rcube_imap_generic
const ERROR_UNKNOWN = -4;
const COMMAND_NORESPONSE = 1;
+ const COMMAND_CAPABILITY = 2;
/**
* Object constructor
@@ -476,7 +477,8 @@ class rcube_imap_generic
// RFC 4959 (SASL-IR): save one round trip
if ($this->getCapability('SASL-IR')) {
- $result = $this->execute("AUTHENTICATE PLAIN", array($reply), self::COMMAND_NORESPONSE);
+ $result = $this->execute("AUTHENTICATE PLAIN", array($reply),
+ self::COMMAND_NORESPONSE | self::COMMAND_CAPABILITY);
}
else {
$this->putLine($this->next_tag() . " AUTHENTICATE PLAIN");
@@ -494,6 +496,10 @@ class rcube_imap_generic
}
if ($result == self::ERROR_OK) {
+ // optional CAPABILITY response
+ if ($line && preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) {
+ $this->parseCapability($matches[1]);
+ }
return $this->fp;
}
else {
@@ -514,7 +520,7 @@ class rcube_imap_generic
function login($user, $password)
{
list($code, $response) = $this->execute('LOGIN', array(
- $this->escape($user), $this->escape($password)));
+ $this->escape($user), $this->escape($password)), self::COMMAND_CAPABILITY);
// re-set capabilities list if untagged CAPABILITY response provided
if (preg_match('/\* CAPABILITY (.+)/i', $response, $matches)) {
@@ -2802,6 +2808,13 @@ class rcube_imap_generic
$response = substr($response, 0, -$line_len);
}
+ // optional CAPABILITY response
+ if (($options & self::COMMAND_CAPABILITY) && $code == self::ERROR_OK
+ && preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)
+ ) {
+ $this->parseCapability($matches[1]);
+ }
+
return $noresp ? $code : array($code, $response);
}