Http.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_Amf
  17. * @subpackage Request
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /** Zend_Amf_Request */
  22. require_once 'Zend/Amf/Request.php';
  23. /**
  24. * AMF Request object -- Request via HTTP
  25. *
  26. * Extends {@link Zend_Amf_Request} to accept a request via HTTP. Request is
  27. * built at construction time using a raw POST; if no data is available, the
  28. * request is declared a fault.
  29. *
  30. * @package Zend_Amf
  31. * @subpackage Request
  32. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Amf_Request_Http extends Zend_Amf_Request
  36. {
  37. /**
  38. * Raw AMF request
  39. * @var string
  40. */
  41. protected $_rawRequest;
  42. /**
  43. * Constructor
  44. *
  45. * Attempts to read from php://input to get raw POST request; if an error
  46. * occurs in doing so, or if the AMF body is invalid, the request is declared a
  47. * fault.
  48. *
  49. * @return void
  50. */
  51. public function __construct()
  52. {
  53. // php://input allows you to read raw POST data. It is a less memory
  54. // intensive alternative to $HTTP_RAW_POST_DATA and does not need any
  55. // special php.ini directives
  56. $amfRequest = file_get_contents('php://input');
  57. // Check to make sure that we have data on the input stream.
  58. if ($amfRequest != '') {
  59. $this->_rawRequest = $amfRequest;
  60. $this->initialize($amfRequest);
  61. } else {
  62. echo '<p>Zend Amf Endpoint</p>' ;
  63. }
  64. }
  65. /**
  66. * Retrieve raw AMF Request
  67. *
  68. * @return string
  69. */
  70. public function getRawRequest()
  71. {
  72. return $this->_rawRequest;
  73. }
  74. }