Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Working on the Http Client, making persistant cookies work

  • Loading branch information...
commit 3f6e54d343ec4e08817ca26937c568917cc29ca8 1 parent 2c58012
Joseph Crawford authored
View
9 library/Zend/Http/Client.php
@@ -835,7 +835,7 @@ public function send(Request $request = null)
if ($cookie->getFieldValue()) {
$headers['Cookie'] = $cookie->getFieldValue();
}
-
+
// check that adapter supports streaming before using it
if (is_resource($body) && !($this->adapter instanceof Client\Adapter\StreamInterface)) {
throw new Client\Exception\RuntimeException('Adapter does not support streaming');
@@ -881,9 +881,9 @@ public function send(Request $request = null)
}
// Get the cookies from response (if any)
- $setCookie = $response->getCookie();
- if (!empty($setCookie)) {
- $this->addCookie($setCookie);
+ $setCookies = $response->getCookie();
+ if (!empty($setCookies)) {
+ $this->addCookie($setCookies);
}
// If we got redirected, look for the Location header
@@ -1320,7 +1320,6 @@ protected function doRequest(Http $uri, $method, $secure = false, $headers = arr
throw new Exception\RuntimeException('Adapter does not support streaming');
}
}
-
// HTTP connection
$this->lastRawRequest = $this->adapter->write($method,
$uri, $this->config['httpversion'], $headers, $body);
View
5 library/Zend/Http/Client/Adapter/Curl.php
@@ -374,6 +374,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
foreach ($headers as $key => $value) {
$curlHeaders[] = $key . ': ' . $value;
}
+
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $curlHeaders);
/**
@@ -409,13 +410,13 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
}
// send the request
- $response = curl_exec($this->curl);
+ $response = curl_exec($this->curl);
// if we used streaming, headers are already there
if (!is_resource($this->outputStream)) {
$this->response = $response;
}
-
+
$request = curl_getinfo($this->curl, CURLINFO_HEADER_OUT);
$request .= $body;
View
10 library/Zend/Http/Header/SetCookie.php
@@ -98,6 +98,7 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
$setCookieProcessor = function($headerLine) use ($setCookieClass) {
$header = new $setCookieClass;
$keyValuePairs = preg_split('#;\s*#', $headerLine);
+
foreach ($keyValuePairs as $keyValue) {
if (strpos($keyValue, '=')) {
list($headerKey, $headerValue) = preg_split('#=\s*#', $keyValue, 2);
@@ -112,7 +113,7 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
$header->setValue(urldecode($headerValue));
continue;
}
-
+
// Process the remaining elements
switch (str_replace(array('-', '_'), '', strtolower($headerKey))) {
case 'expires' : $header->setExpires($headerValue); break;
@@ -563,14 +564,9 @@ public static function matchCookieDomain($cookieDomain, $host)
$cookieDomain = strtolower($cookieDomain);
$host = strtolower($host);
-
- if ($cookieDomain[0] == '.') {
- $cookieDomain = substr($cookieDomain, 1);
- }
-
// Check for either exact match or suffix match
return ($cookieDomain == $host ||
- preg_match('/\.' . preg_quote($cookieDomain) . '$/', $host));
+ preg_match('/' . preg_quote($cookieDomain) . '$/', $host));
}
/**

0 comments on commit 3f6e54d

Please sign in to comment.
Something went wrong with that request. Please try again.