]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Oauth.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Oauth.php
1 <?php
2 /**
3  * Zend Framework
4  *
5  * LICENSE
6  *
7  * This source file is subject to the new BSD license that is bundled
8  * with this package in the file LICENSE.txt.
9  * It is also available through the world-wide-web at this URL:
10  * http://framework.zend.com/license/new-bsd
11  * If you did not receive a copy of the license and are unable to
12  * obtain it through the world-wide-web, please send an email
13  * to license@zend.com so we can send you a copy immediately.
14  *
15  * @category   Zend
16  * @package    Zend_Oauth
17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
19
20  */
21
22 /** Zend_Http_Client */
23 require_once 'Zend/Http/Client.php';
24
25 /**
26  * @category   Zend
27  * @package    Zend_Oauth
28  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
30  */
31 class Zend_Oauth
32 {
33     const REQUEST_SCHEME_HEADER      = 'header';
34     const REQUEST_SCHEME_POSTBODY    = 'postbody';
35     const REQUEST_SCHEME_QUERYSTRING = 'querystring';
36     const GET                        = 'GET';
37     const POST                       = 'POST';
38     const PUT                        = 'PUT';
39     const DELETE                     = 'DELETE';
40     const HEAD                       = 'HEAD';
41
42     /**
43      * Singleton instance if required of the HTTP client
44      *
45      * @var Zend_Http_Client
46      */
47     protected static $httpClient = null;
48
49     /**
50      * Allows the external environment to make Zend_Oauth use a specific
51      * Client instance.
52      *
53      * @param Zend_Http_Client $httpClient
54      * @return void
55      */
56     public static function setHttpClient(Zend_Http_Client $httpClient)
57     {
58         self::$httpClient = $httpClient;
59     }
60
61     /**
62      * Return the singleton instance of the HTTP Client. Note that
63      * the instance is reset and cleared of previous parameters and
64      * Authorization header values.
65      *
66      * @return Zend_Http_Client
67      */
68     public static function getHttpClient()
69     {
70         if (!isset(self::$httpClient)) {
71             self::$httpClient = new Zend_Http_Client;
72         } else {
73             self::$httpClient->setHeaders('Authorization', null);
74             self::$httpClient->resetParameters();
75         }
76         return self::$httpClient;
77     }
78
79     /**
80      * Simple mechanism to delete the entire singleton HTTP Client instance
81      * which forces an new instantiation for subsequent requests.
82      *
83      * @return void
84      */
85     public static function clearHttpClient()
86     {
87         self::$httpClient = null;
88     }
89 }