Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / XmlRpc / Request / Http.php
blobc8425d3ef98cffb16071c4848ed6db158dee9a06
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\XmlRpc\Request;
12 use Zend\Stdlib\ErrorHandler;
13 use Zend\XmlRpc\Fault;
14 use Zend\XmlRpc\Request as XmlRpcRequest;
16 /**
17 * XmlRpc Request object -- Request via HTTP
19 * Extends {@link Zend\XmlRpc\Request} to accept a request via HTTP. Request is
20 * built at construction time using a raw POST; if no data is available, the
21 * request is declared a fault.
23 class Http extends XmlRpcRequest
25 /**
26 * Array of headers
27 * @var array
29 protected $headers;
31 /**
32 * Raw XML as received via request
33 * @var string
35 protected $xml;
37 /**
38 * Constructor
40 * Attempts to read from php://input to get raw POST request; if an error
41 * occurs in doing so, or if the XML is invalid, the request is declared a
42 * fault.
45 public function __construct()
47 ErrorHandler::start();
48 $xml = file_get_contents('php://input');
49 ErrorHandler::stop();
50 if (!$xml) {
51 $this->fault = new Fault(630);
52 return;
55 $this->xml = $xml;
57 $this->loadXml($xml);
60 /**
61 * Retrieve the raw XML request
63 * @return string
65 public function getRawRequest()
67 return $this->xml;
70 /**
71 * Get headers
73 * Gets all headers as key => value pairs and returns them.
75 * @return array
77 public function getHeaders()
79 if (null === $this->headers) {
80 $this->headers = array();
81 foreach ($_SERVER as $key => $value) {
82 if ('HTTP_' == substr($key, 0, 5)) {
83 $header = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
84 $this->headers[$header] = $value;
89 return $this->headers;
92 /**
93 * Retrieve the full HTTP request, including headers and XML
95 * @return string
97 public function getFullRequest()
99 $request = '';
100 foreach ($this->getHeaders() as $key => $value) {
101 $request .= $key . ': ' . $value . "\n";
104 $request .= $this->xml;
106 return $request;