File indexing completed on 2024-04-28 06:00:02

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Oauth
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /** Zend_Http_Client */
0023 // require_once 'Zend/Http/Client.php';
0024 
0025 /**
0026  * @category   Zend
0027  * @package    Zend_Oauth
0028  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0029  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0030  */
0031 class Zend_Oauth
0032 {
0033     const REQUEST_SCHEME_HEADER      = 'header';
0034     const REQUEST_SCHEME_POSTBODY    = 'postbody';
0035     const REQUEST_SCHEME_QUERYSTRING = 'querystring';
0036     const GET                        = 'GET';
0037     const POST                       = 'POST';
0038     const PUT                        = 'PUT';
0039     const DELETE                     = 'DELETE';
0040     const HEAD                       = 'HEAD';
0041     const OPTIONS                    = 'OPTIONS';
0042 
0043     /**
0044      * Singleton instance if required of the HTTP client
0045      *
0046      * @var Zend_Http_Client
0047      */
0048     protected static $httpClient = null;
0049 
0050     /**
0051      * Allows the external environment to make Zend_Oauth use a specific
0052      * Client instance.
0053      *
0054      * @param Zend_Http_Client $httpClient
0055      * @return void
0056      */
0057     public static function setHttpClient(Zend_Http_Client $httpClient)
0058     {
0059         self::$httpClient = $httpClient;
0060     }
0061 
0062     /**
0063      * Return the singleton instance of the HTTP Client. Note that
0064      * the instance is reset and cleared of previous parameters and
0065      * Authorization header values.
0066      *
0067      * @return Zend_Http_Client
0068      */
0069     public static function getHttpClient()
0070     {
0071         if (!isset(self::$httpClient)) {
0072             self::$httpClient = new Zend_Http_Client;
0073         } else {
0074             self::$httpClient->setHeaders('Authorization', null);
0075             self::$httpClient->resetParameters();
0076         }
0077         return self::$httpClient;
0078     }
0079 
0080     /**
0081      * Simple mechanism to delete the entire singleton HTTP Client instance
0082      * which forces an new instantiation for subsequent requests.
0083      *
0084      * @return void
0085      */
0086     public static function clearHttpClient()
0087     {
0088         self::$httpClient = null;
0089     }
0090 }