117 if ( !$this->status->isOK() ) {
118 return Status::wrap( $this->status );
121 if ( $this->proxy ) {
122 $this->guzzleOptions[
'proxy'] = $this->proxy;
125 $this->guzzleOptions[
'timeout'] = $this->timeout;
126 $this->guzzleOptions[
'connect_timeout'] = $this->connectTimeout;
127 $this->guzzleOptions[
'version'] =
'1.1';
129 if ( !$this->followRedirects ) {
130 $this->guzzleOptions[
'allow_redirects'] =
false;
132 $this->guzzleOptions[
'allow_redirects'] = [
133 'max' => $this->maxRedirects
137 if ( $this->method ==
'POST' ) {
140 $this->guzzleOptions[
'form_params'] =
$postData;
142 $this->guzzleOptions[
'body'] =
$postData;
144 if ( !isset( $this->reqHeaders[
'Content-Type'] ) ) {
145 $this->reqHeaders[
'Content-Type'] =
'application/x-www-form-urlencoded';
152 $this->guzzleOptions[
'expect'] =
false;
155 $this->guzzleOptions[
'headers'] = $this->reqHeaders;
157 if ( $this->handler ) {
158 $this->guzzleOptions[
'handler'] = $this->handler;
162 $this->guzzleOptions[
'sink'] = $this->sink;
165 if ( $this->caInfo ) {
166 $this->guzzleOptions[
'verify'] = $this->caInfo;
167 } elseif ( !$this->sslVerifyHost && !$this->sslVerifyCert ) {
168 $this->guzzleOptions[
'verify'] =
false;
172 $client =
new Client( $this->guzzleOptions );
173 $request =
new Request( $this->method, $this->url );
175 $this->headerList =
$response->getHeaders();
177 $this->respVersion =
$response->getProtocolVersion();
179 }
catch ( GuzzleHttp\Exception\ConnectException $e ) {
187 $handlerContext = $e->getHandlerContext();
188 if ( $handlerContext[
'errno'] == CURLE_OPERATION_TIMEOUTED ) {
189 $this->status->fatal(
'http-timed-out', $this->url );
191 $this->status->fatal(
'http-curl-error', $handlerContext[
'error'] );
194 $this->status->fatal(
'http-request-error' );
196 }
catch ( GuzzleHttp\Exception\RequestException $e ) {
198 $handlerContext = $e->getHandlerContext();
199 $this->status->fatal(
'http-curl-error', $handlerContext[
'error'] );
202 $needle =
'Connection timed out';
203 if ( strpos( $e->getMessage(), $needle ) !==
false ) {
204 $this->status->fatal(
'http-timed-out', $this->url );
206 $this->status->fatal(
'http-request-error' );
209 }
catch ( GuzzleHttp\Exception\GuzzleException $e ) {
210 $this->status->fatal(
'http-internal-error' );
213 if ( $this->profiler ) {
214 $profileSection = $this->profiler->scopedProfileIn(
215 __METHOD__ .
'-' . $this->profileName
219 if ( $this->profiler ) {
220 $this->profiler->scopedProfileOut( $profileSection );
226 return Status::wrap( $this->status );