timeout = $timeout; } /** * @param string $request * @param string $location * @param string $action * @param int $version * @param bool $one_way * @return mixed|string * @throws Exception */ public function __doRequest( $request, $location, $action, $version, $one_way = false ) { if ( !$this->timeout ) { // Call via parent because we require no timeout $response = parent::__doRequest( $request, $location, $action, $version, $one_way ); } else { // Call via Curl and use the timeout $curl = curl_init( $location ); curl_setopt( $curl, CURLOPT_VERBOSE, false ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $curl, CURLOPT_POST, true ); curl_setopt( $curl, CURLOPT_POSTFIELDS, $request ); curl_setopt( $curl, CURLOPT_HEADER, false ); curl_setopt( $curl, CURLOPT_HTTPHEADER, [ "Content-Type: text/xml" ] ); curl_setopt( $curl, CURLOPT_TIMEOUT, $this->timeout ); $response = curl_exec( $curl ); if ( curl_errno( $curl ) ) { throw new Exception( curl_error( $curl ) ); } curl_close( $curl ); } // Return? if ( !$one_way ) { return $response; } return false; } } ?>