[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/XmlRpc/Request/ -> Http.php (source)

   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 [email protected] so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Controller
  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_XmlRpc_Request
  23   */
  24  require_once 'Zend/XmlRpc/Request.php';
  25  
  26  /**
  27   * XmlRpc Request object -- Request via HTTP
  28   *
  29   * Extends {@link Zend_XmlRpc_Request} to accept a request via HTTP. Request is
  30   * built at construction time using a raw POST; if no data is available, the
  31   * request is declared a fault.
  32   *
  33   * @category Zend
  34   * @package  Zend_XmlRpc
  35   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  36   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  37   * @version $Id$
  38   */
  39  class Zend_XmlRpc_Request_Http extends Zend_XmlRpc_Request
  40  {
  41      /**
  42       * Array of headers
  43       * @var array
  44       */
  45      protected $_headers;
  46  
  47      /**
  48       * Raw XML as received via request
  49       * @var string
  50       */
  51      protected $_xml;
  52  
  53      /**
  54       * Constructor
  55       *
  56       * Attempts to read from php://input to get raw POST request; if an error
  57       * occurs in doing so, or if the XML is invalid, the request is declared a
  58       * fault.
  59       *
  60       * @return void
  61       */
  62      public function __construct()
  63      {
  64          $xml = @file_get_contents('php://input');
  65          if (!$xml) {
  66              require_once 'Zend/XmlRpc/Fault.php';
  67              $this->_fault = new Zend_XmlRpc_Fault(630);
  68              return;
  69          }
  70  
  71          $this->_xml = $xml;
  72  
  73          $this->loadXml($xml);
  74      }
  75  
  76      /**
  77       * Retrieve the raw XML request
  78       *
  79       * @return string
  80       */
  81      public function getRawRequest()
  82      {
  83          return $this->_xml;
  84      }
  85  
  86      /**
  87       * Get headers
  88       *
  89       * Gets all headers as key => value pairs and returns them.
  90       *
  91       * @return array
  92       */
  93      public function getHeaders()
  94      {
  95          if (null === $this->_headers) {
  96              $this->_headers = array();
  97              foreach ($_SERVER as $key => $value) {
  98                  if ('HTTP_' == substr($key, 0, 5)) {
  99                      $header = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
 100                      $this->_headers[$header] = $value;
 101                  }
 102              }
 103          }
 104  
 105          return $this->_headers;
 106      }
 107  
 108      /**
 109       * Retrieve the full HTTP request, including headers and XML
 110       *
 111       * @return string
 112       */
 113      public function getFullRequest()
 114      {
 115          $request = '';
 116          foreach ($this->getHeaders() as $key => $value) {
 117              $request .= $key . ': ' . $value . "\n";
 118          }
 119  
 120          $request .= $this->_xml;
 121  
 122          return $request;
 123      }
 124  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1