Magento file: lib/Zend/XmlRpc/Request/Http.php

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

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