Http.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_Json
  17. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * @see Zend_Json_Server_Request
  23. */
  24. require_once 'Zend/Json/Server/Request.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Json
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Json_Server_Request_Http extends Zend_Json_Server_Request
  32. {
  33. /**
  34. * Raw JSON pulled from POST body
  35. * @var string
  36. */
  37. protected $_rawJson;
  38. /**
  39. * Constructor
  40. *
  41. * Pull JSON request from raw POST body and use to populate request.
  42. *
  43. * @return void
  44. */
  45. public function __construct()
  46. {
  47. $json = file_get_contents('php://input');
  48. $this->_rawJson = $json;
  49. if (!empty($json)) {
  50. $this->loadJson($json);
  51. }
  52. }
  53. /**
  54. * Get JSON from raw POST body
  55. *
  56. * @return string
  57. */
  58. public function getRawJson()
  59. {
  60. return $this->_rawJson;
  61. }
  62. }