Microsoft_Http
[ class tree: Microsoft_Http ] [ index: Microsoft_Http ] [ all elements ]

Class: Microsoft_Http_CookieJar

Source Location: /Http/CookieJar.php

Class Overview


A Microsoft_Http_CookieJar object is designed to contain and maintain HTTP cookies, and should be used along with Microsoft_Http_Client in order to manage cookies across HTTP requests and responses.


Author(s):

Copyright:

  • Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)

Implements interfaces:

  • Countable (internal interface)
  • IteratorAggregate (internal interface)

Variables

Constants

Methods



Class Details

[line 52]
A Microsoft_Http_CookieJar object is designed to contain and maintain HTTP cookies, and should be used along with Microsoft_Http_Client in order to manage cookies across HTTP requests and responses.

The class contains an array of Microsoft_Http_Cookie objects. Cookies can be added to the jar automatically from a request or manually. Then, the jar can find and return the cookies needed for a specific HTTP request.

A special parameter can be passed to all methods of this class that return cookies: Cookies can be returned either in their native form (as Microsoft_Http_Cookie objects) or as strings - the later is suitable for sending as the value of the "Cookie" header in an HTTP request. You can also choose, when returning more than one cookie, whether to get an array of strings (by passing Microsoft_Http_CookieJar::COOKIE_STRING_ARRAY) or one unified string for all cookies (by passing Microsoft_Http_CookieJar::COOKIE_STRING_CONCAT).




Tags:

copyright:  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
link:  for some specs.
license:  New BSD License


[ Top ]


Class Variables

$cookies = array()

[line 89]

Array storing cookies

Cookies are stored according to domain and path: $cookies

    • / - cookie1 - cookie2
      • / - alsocookie




      Tags:

      access:  protected

      Type:   array


      [ Top ]

      $_rawCookies = array()

      [line 96]

      The Microsoft_Http_Cookie array



      Tags:

      access:  protected

      Type:   array


      [ Top ]



      Class Methods


      static method fromResponse [line 348]

      static Microsoft_Http_CookieJar fromResponse( Microsoft_Http_Response $response, $ref_uri, Microsoft_Uri_Http|string $uri)

      Create a new CookieJar object and automatically load into it all the cookies set in an Http_Response object. If $uri is set, it will be considered as the requested URI for setting default domain and path of the cookie.



      Tags:

      todo:  Add the $uri functionality.
      access:  public


      Parameters:

      Microsoft_Http_Response   $response   HTTP Response object
      Microsoft_Uri_Http|string   $uri   The requested URI
         $ref_uri  

      [ Top ]

      constructor __construct [line 102]

      Microsoft_Http_CookieJar __construct( )

      Construct a new CookieJar object



      Tags:

      access:  public


      [ Top ]

      method addCookie [line 112]

      void addCookie( Microsoft_Http_Cookie|string $cookie, [Microsoft_Uri_Http|string $ref_uri = null])

      Add a cookie to the jar. Cookie should be passed either as a Microsoft_Http_Cookie object or as a string - in which case an object is created from the string.



      Tags:

      access:  public


      Parameters:

      Microsoft_Http_Cookie|string   $cookie  
      Microsoft_Uri_Http|string   $ref_uri   Optional reference URI (for domain, path, secure)

      [ Top ]

      method addCookiesFromResponse [line 138]

      void addCookiesFromResponse( Microsoft_Http_Response $response, Microsoft_Uri_Http|string $ref_uri)

      Parse an HTTP response, adding all the cookies set in that response to the cookie jar.



      Tags:

      access:  public


      Parameters:

      Microsoft_Http_Response   $response  
      Microsoft_Uri_Http|string   $ref_uri   Requested URI

      [ Top ]

      method count [line 360]

      int count( )

      Required by Countable interface



      Tags:

      access:  public



      Implementation of:
      Countable::count
      [ Top ]

      method getAllCookies [line 163]

      array|string getAllCookies( [int $ret_as = self::COOKIE_OBJECT])

      Get all cookies in the cookie jar as an array



      Tags:

      access:  public


      Parameters:

      int   $ret_as   Whether to return cookies as objects of Microsoft_Http_Cookie or as strings

      [ Top ]

      method getCookie [line 214]

      Microsoft_Http_Cookie|string getCookie( Microsoft_Uri_Http|string $uri, string $cookie_name, [int $ret_as = self::COOKIE_OBJECT])

      Get a specific cookie according to a URI and name



      Tags:

      access:  public


      Parameters:

      Microsoft_Uri_Http|string   $uri   The uri (domain and path) to match
      string   $cookie_name   The cookie's name
      int   $ret_as   Whether to return cookies as objects of Microsoft_Http_Cookie or as strings

      [ Top ]

      method getIterator [line 370]

      ArrayIterator getIterator( )

      Required by IteratorAggregate interface



      Tags:

      access:  public



      Implementation of:
      IteratorAggregate::getIterator
      [ Top ]

      method getMatchingCookies [line 180]

      array|string getMatchingCookies( string|Microsoft_Uri_Http $uri, [boolean $matchSessionCookies = true], [int $ret_as = self::COOKIE_OBJECT], [int $now = null])

      Return an array of all cookies matching a specific request according to the request URI, whether session cookies should be sent or not, and the time to consider as "now" when checking cookie expiry time.



      Tags:

      access:  public


      Parameters:

      string|Microsoft_Uri_Http   $uri   URI to check against (secure, domain, path)
      boolean   $matchSessionCookies   Whether to send session cookies
      int   $ret_as   Whether to return cookies as objects of Microsoft_Http_Cookie or as strings
      int   $now   Override the current time when checking for expiry time

      [ Top ]

      method isEmpty [line 380]

      bool isEmpty( )

      Tells if the jar is empty of any cookie



      Tags:

      access:  public


      [ Top ]

      method reset [line 390]

      Microsoft_Http_CookieJar reset( )

      Empties the cookieJar of any cookie



      Tags:

      access:  public


      [ Top ]

      method _flattenCookiesArray [line 261]

      array|string _flattenCookiesArray( Microsoft_Http_Cookie|array $ptr, [int $ret_as = self::COOKIE_OBJECT])

      Helper function to recursivly flatten an array. Shoud be used when exporting the cookies array (or parts of it)



      Tags:

      access:  protected


      Parameters:

      Microsoft_Http_Cookie|array   $ptr  
      int   $ret_as   What value to return

      [ Top ]

      method _matchDomain [line 298]

      array _matchDomain( string $domain)

      Return a subset of the cookies array matching a specific domain



      Tags:

      access:  protected


      Parameters:

      string   $domain  

      [ Top ]

      method _matchPath [line 318]

      array _matchPath( $domains, string $path, array $dom_array)

      Return a subset of a domain-matching cookies that also match a specified path



      Tags:

      access:  protected


      Parameters:

      array   $dom_array  
      string   $path  
         $domains  

      [ Top ]


      Class Constants

      COOKIE_OBJECT =  0

      [line 58]

      Return cookie(s) as a Microsoft_Http_Cookie object


      [ Top ]

      COOKIE_STRING_ARRAY =  1

      [line 64]

      Return cookie(s) as a string (suitable for sending in an HTTP request)


      [ Top ]

      COOKIE_STRING_CONCAT =  2

      [line 70]

      Return all cookies as one long string (suitable for sending in an HTTP request)


      [ Top ]



      Documentation generated on Wed, 18 May 2011 12:06:27 +0200 by phpDocumentor 1.4.3