GetCorsResult.php 767 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace OSS\Result;
  3. use OSS\Model\CorsConfig;
  4. class GetCorsResult extends Result
  5. {
  6. /**
  7. * @return CorsConfig
  8. */
  9. protected function parseDataFromResponse()
  10. {
  11. $content = $this->rawResponse->body;
  12. $config = new CorsConfig();
  13. $config->parseFromXml($content);
  14. return $config;
  15. }
  16. /**
  17. * Check if the response is OK, according to the http status. [200-299]:OK, the Cors config could be got; [404]: not found--no Cors config.
  18. *
  19. * @return bool
  20. */
  21. protected function isResponseOk()
  22. {
  23. $status = $this->rawResponse->status;
  24. if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) {
  25. return true;
  26. }
  27. return false;
  28. }
  29. }