Changeset View
Changeset View
Standalone View
Standalone View
include/network/HTTPRequest.php
Show First 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | public function fetch( $data = [], $args = [] ) { | ||||
// Check the HTTP status | // Check the HTTP status | ||||
$http_status = $this->getLatestHTTPResponseStatus(); | $http_status = $this->getLatestHTTPResponseStatus(); | ||||
// no status no party | // no status no party | ||||
if( !$http_status ) { | if( !$http_status ) { | ||||
// oh nose! | // oh nose! | ||||
Log::error( "Huston, we have not valid headers" ); | Log::error( "Houston, we have not valid headers" ); | ||||
// retry but without DOSsing | // retry but without DOSsing | ||||
$args = array_replace( $args, [ | $args = array_replace( $args, [ | ||||
'wait-anti-dos' => true, | 'wait-anti-dos' => true, | ||||
] ); | ] ); | ||||
// retry... | // retry... | ||||
return $this->fetch( $data, $args ); | return $this->fetch( $data, $args ); | ||||
} elseif( !$http_status->isOK() ) { | } elseif( !$http_status->isOK() ) { | ||||
// retry again if it's a server error | // retry again if it's a server error | ||||
if( $http_status->isServerError() ) { | if( $http_status->isServerError() ) { | ||||
// oh nose! | // oh nose! | ||||
Log::error( sprintf( "Huston, we have the code %s: %s", | Log::error( sprintf( "Houston, we have the code %s: %s", | ||||
$http_status->getCode(), | $http_status->getCode(), | ||||
$http_status->getMessage() | $http_status->getMessage() | ||||
) ); | ) ); | ||||
// retry but without DOSsing | // retry but without DOSsing | ||||
$args = array_replace( $args, [ | $args = array_replace( $args, [ | ||||
'wait-anti-dos' => true, | 'wait-anti-dos' => true, | ||||
] ); | ] ); | ||||
▲ Show 20 Lines • Show All 387 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register