Http.php 2.3 KB

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