File indexing completed on 2025-01-26 05:30:06

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_Controller
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  */
0020 
0021 /**
0022  * Zend_XmlRpc_Request
0023  */
0024 // require_once 'Zend/XmlRpc/Request.php';
0025 
0026 /**
0027  * XmlRpc Request object -- Request via HTTP
0028  *
0029  * Extends {@link Zend_XmlRpc_Request} to accept a request via HTTP. Request is
0030  * built at construction time using a raw POST; if no data is available, the
0031  * request is declared a fault.
0032  *
0033  * @category Zend
0034  * @package  Zend_XmlRpc
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  * @version $Id$
0038  */
0039 class Zend_XmlRpc_Request_Http extends Zend_XmlRpc_Request
0040 {
0041     /**
0042      * Array of headers
0043      * @var array
0044      */
0045     protected $_headers;
0046 
0047     /**
0048      * Raw XML as received via request
0049      * @var string
0050      */
0051     protected $_xml;
0052 
0053     /**
0054      * Constructor
0055      *
0056      * Attempts to read from php://input to get raw POST request; if an error
0057      * occurs in doing so, or if the XML is invalid, the request is declared a
0058      * fault.
0059      *
0060      * @return void
0061      */
0062     public function __construct()
0063     {
0064         $xml = @file_get_contents('php://input');
0065         if (!$xml) {
0066             // require_once 'Zend/XmlRpc/Fault.php';
0067             $this->_fault = new Zend_XmlRpc_Fault(630);
0068             return;
0069         }
0070 
0071         $this->_xml = $xml;
0072 
0073         $this->loadXml($xml);
0074     }
0075 
0076     /**
0077      * Retrieve the raw XML request
0078      *
0079      * @return string
0080      */
0081     public function getRawRequest()
0082     {
0083         return $this->_xml;
0084     }
0085 
0086     /**
0087      * Get headers
0088      *
0089      * Gets all headers as key => value pairs and returns them.
0090      *
0091      * @return array
0092      */
0093     public function getHeaders()
0094     {
0095         if (null === $this->_headers) {
0096             $this->_headers = array();
0097             foreach ($_SERVER as $key => $value) {
0098                 if ('HTTP_' == substr($key, 0, 5)) {
0099                     $header = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
0100                     $this->_headers[$header] = $value;
0101                 }
0102             }
0103         }
0104 
0105         return $this->_headers;
0106     }
0107 
0108     /**
0109      * Retrieve the full HTTP request, including headers and XML
0110      *
0111      * @return string
0112      */
0113     public function getFullRequest()
0114     {
0115         $request = '';
0116         foreach ($this->getHeaders() as $key => $value) {
0117             $request .= $key . ': ' . $value . "\n";
0118         }
0119 
0120         $request .= $this->_xml;
0121 
0122         return $request;
0123     }
0124 }