Requests_Response::throw_for_status()
最后更新于:2021-11-26 04:02:41
Requests_Response::throw_for_status( boolean$allow_redirects=true)Throws an exception if the request was not successful
参数
- $allow_redirects
-
(boolean) (Optional) Set to false to throw on a 3xx as well
Default value: true
源文件
文件: gc-includes/Requests/Response.php
public function throw_for_status($allow_redirects = true) {
if ($this->is_redirect()) {
if (!$allow_redirects) {
throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
}
}
elseif (!$this->success) {
$exception = Requests_Exception_HTTP::get_class($this->status_code);
throw new $exception(null, $this);
}
}