305.php 869 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class Kohana_HTTP_Exception_305 extends HTTP_Exception_Expected {
  3. /**
  4. * @var integer HTTP 305 Use Proxy
  5. */
  6. protected $_code = 305;
  7. /**
  8. * Specifies the proxy to replay this request via
  9. *
  10. * @param string $location URI of the proxy
  11. */
  12. public function location($uri = NULL)
  13. {
  14. if ($uri === NULL)
  15. return $this->headers('Location');
  16. $this->headers('Location', $uri);
  17. return $this;
  18. }
  19. /**
  20. * Validate this exception contains everything needed to continue.
  21. *
  22. * @throws Kohana_Exception
  23. * @return bool
  24. */
  25. public function check()
  26. {
  27. if ($location = $this->headers('location') === NULL)
  28. throw new Kohana_Exception('A \'location\' must be specified for a redirect');
  29. if (strpos($location, '://') === FALSE)
  30. throw new Kohana_Exception('An absolute URI to the proxy server must be specified');
  31. return TRUE;
  32. }
  33. }