当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Http_CookieJar::getMatchingCookies方法代码示例

本文整理汇总了PHP中Zend_Http_CookieJar::getMatchingCookies方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_CookieJar::getMatchingCookies方法的具体用法?PHP Zend_Http_CookieJar::getMatchingCookies怎么用?PHP Zend_Http_CookieJar::getMatchingCookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Http_CookieJar的用法示例。


在下文中一共展示了Zend_Http_CookieJar::getMatchingCookies方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _prepareHeaders

 /**
  * Prepare the request headers
  *
  * @return array
  */
 protected function _prepareHeaders()
 {
     $headers = array();
     // Set the host header
     if (!isset($this->headers['host'])) {
         $host = $this->uri->getHost();
         // If the port is not default, add it
         if (!($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80 || $this->uri->getScheme() == 'https' && $this->uri->getPort() == 443)) {
             $host .= ':' . $this->uri->getPort();
         }
         $headers[] = "Host: {$host}";
     }
     // Set the connection header
     if (!isset($this->headers['connection'])) {
         if (!$this->config['keepalive']) {
             $headers[] = "Connection: close";
         }
     }
     // Set the Accept-encoding header if not set - depending on whether
     // zlib is available or not.
     if (!isset($this->headers['accept-encoding'])) {
         if (function_exists('gzinflate')) {
             $headers[] = 'Accept-encoding: gzip, deflate';
         } else {
             $headers[] = 'Accept-encoding: identity';
         }
     }
     // Set the Content-Type header
     if (($this->method == self::POST || $this->method == self::PUT) && (!isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) {
         $headers[] = self::CONTENT_TYPE . ': ' . $this->enctype;
     }
     // Set the user agent header
     if (!isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
         $headers[] = "User-Agent: {$this->config['useragent']}";
     }
     // Set HTTP authentication if needed
     if (is_array($this->auth)) {
         $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']);
         $headers[] = "Authorization: {$auth}";
     }
     // Load cookies from cookie jar
     if (isset($this->cookiejar)) {
         $cookstr = $this->cookiejar->getMatchingCookies($this->uri, true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
         if ($cookstr) {
             $headers[] = "Cookie: {$cookstr}";
         }
     }
     // Add all other user defined headers
     foreach ($this->headers as $header) {
         list($name, $value) = $header;
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         $headers[] = "{$name}: {$value}";
     }
     return $headers;
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:62,代码来源:Client.php

示例2: prepare_headers

 /**
  * Prepare the request headers
  *
  * @return array
  */
 protected function prepare_headers()
 {
     $headers = array();
     // Set the host header
     if (!isset($this->headers['host'])) {
         $host = $this->uri->getHost();
         // If the port is not default, add it
         if (!($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80 || $this->uri->getScheme() == 'https' && $this->uri->getPort() == 443)) {
             $host .= ':' . $this->uri->getPort();
         }
         $headers[] = "Host: {$host}";
     }
     // Set the connection header
     if (!isset($this->headers['connection'])) {
         if (!$this->config['keepalive']) {
             $headers[] = "Connection: close";
         }
     }
     // Set the content-type header
     if ($this->method == self::POST && (!isset($this->headers['content-type']) && isset($this->enctype))) {
         $headers[] = "Content-type: {$this->enctype}";
     }
     // Set the user agent header
     if (!isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
         $headers[] = "User-agent: {$this->config['useragent']}";
     }
     // Set HTTP authentication if needed
     if (is_array($this->auth)) {
         $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']);
         $headers[] = "Authorization: {$auth}";
     }
     // Load cookies from cookie jar
     if (isset($this->cookiejar)) {
         $cookstr = $this->cookiejar->getMatchingCookies($this->uri, true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
         if ($cookstr) {
             $headers[] = "Cookie: {$cookstr}";
         }
     }
     // Add all other user defined headers
     foreach ($this->headers as $name => $value) {
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         $headers[] = ucfirst($name) . ": {$value}";
     }
     return $headers;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:52,代码来源:Client.php

示例3: testMatchPathWithTrailingSlash

 /**
  * Make sure that paths with trailing slashes are matched as well as paths with no trailing slashes
  */
 public function testMatchPathWithTrailingSlash()
 {
     $jar = new Zend_Http_CookieJar();
     $cookies = array(Zend_Http_Cookie::fromString('foo1=bar1; domain=.example.com; path=/a/b'), Zend_Http_Cookie::fromString('foo2=bar2; domain=.example.com; path=/a/b/'));
     foreach ($cookies as $cookie) {
         $jar->addCookie($cookie);
     }
     $cookies = $jar->getMatchingCookies('http://www.example.com/a/b/file.txt');
     $this->assertTrue(is_array($cookies));
     $this->assertEquals(2, count($cookies));
 }
开发者ID:JeancarloPerez,项目名称:booking-system,代码行数:14,代码来源:CookieJarTest.php

示例4: _prepareHeaders

 /**
  * Prepare the request headers
  *
  * @return array
  */
 protected function _prepareHeaders()
 {
     $uri = $this->uri;
     $headers = array();
     // Set the host header
     if (!isset($this->headers["host"])) {
         $host = $uri->host;
         $port = (int) $uri->port;
         // If the port is not default, add it
         if (!($uri->scheme === "http" && $port === 80 || $uri->scheme === "https" && $port === 443)) {
             $host .= ":" . $port;
         }
         $headers[] = "Host: {$host}";
     }
     // Set the connection header
     if (!isset($this->headers["connection"])) {
         if (!$this->config["keepalive"]) {
             $headers[] = "Connection: close";
         }
     }
     // Set the Accept-encoding header if not set - depending on whether
     // zlib is available or not.
     if (!isset($this->headers["accept-encoding"])) {
         if (function_exists("gzinflate")) {
             $headers[] = "Accept-encoding: gzip, deflate";
         } else {
             $headers[] = "Accept-encoding: identity";
         }
     }
     // Set the Content-Type header
     if ($this->method === self::POST && (!isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) {
         $headers[] = self::CONTENT_TYPE . ": " . $this->enctype;
     }
     // Set the user agent header
     if (!isset($this->headers["user-agent"]) && isset($this->config["useragent"])) {
         $headers[] = "User-Agent: {$this->config['useragent']}";
     }
     // Set HTTP authentication if needed
     if (is_array($this->auth)) {
         $auth = self::encodeAuthHeader($this->auth["user"], $this->auth["password"], $this->auth["type"]);
         $headers[] = "Authorization: {$auth}";
     }
     // Load cookies from cookie jar
     if (isset($this->cookiejar)) {
         $cookstr = $this->cookiejar->getMatchingCookies($uri, true, Sabel_Http_CookieJar::COOKIE_STRING_CONCAT);
         if ($cookstr) {
             $headers[] = "Cookie: {$cookstr}";
         }
     }
     // Add all other user defined headers
     foreach ($this->headers as $header) {
         list($name, $value) = $header;
         if (is_array($value)) {
             $value = implode(", ", $value);
         }
         $headers[] = "{$name}: {$value}";
     }
     return $headers;
 }
开发者ID:reoring,项目名称:sabel,代码行数:64,代码来源:Client.php

示例5: testGetMatchingCookiesAsStrings

 /**
  * Test we can get all matching cookies for a request, and return as strings array / concat
  */
 public function testGetMatchingCookiesAsStrings()
 {
     $jar = new Zend_Http_CookieJar();
     $cookies = array(Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)), Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'), Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)));
     foreach ($cookies as $cookie) {
         $jar->addCookie($cookie);
     }
     $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
     $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
     $this->assertType('array', $cookies, '$cookies is expected to be an array, but it is not');
     $this->assertType('string', $cookies[0], '$cookies[0] is expected to be a string');
     $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
     $this->assertType('string', $cookies, '$cookies is expected to be a string');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:17,代码来源:CookieJarTest.php

示例6: _getMatchCookieValue

 private function _getMatchCookieValue($name, $domain, Zend_Http_CookieJar $jar)
 {
     $cookies = $jar->getMatchingCookies($domain);
     foreach ($cookies as $cookie) {
         /* @var $cookie Zend_Http_Cookie */
         if ($cookie->getName() == $name) {
             return $cookie->getValue();
         }
     }
     return false;
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:11,代码来源:MegavideoController.php


注:本文中的Zend_Http_CookieJar::getMatchingCookies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。