response.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @author Lukas Reschke <lukas@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OC\Http\Client;
  22. use OCP\Http\Client\IResponse;
  23. use GuzzleHttp\Message\Response as GuzzleResponse;
  24. /**
  25. * Class Response
  26. *
  27. * @package OC\Http
  28. */
  29. class Response implements IResponse {
  30. /** @var GuzzleResponse */
  31. private $response;
  32. /**
  33. * @param GuzzleResponse $response
  34. */
  35. public function __construct(GuzzleResponse $response) {
  36. $this->response = $response;
  37. }
  38. /**
  39. * @return string
  40. */
  41. public function getBody() {
  42. return $this->response->getBody()->getContents();
  43. }
  44. /**
  45. * @return int
  46. */
  47. public function getStatusCode() {
  48. return $this->response->getStatusCode();
  49. }
  50. /**
  51. * @param $key
  52. * @return string
  53. */
  54. public function getHeader($key) {
  55. return $this->response->getHeader($key);
  56. }
  57. /**
  58. * @return array
  59. */
  60. public function getHeaders() {
  61. return $this->response->getHeaders();
  62. }
  63. }