You are here

public static function CurlFactory::finish in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php \GuzzleHttp\Handler\CurlFactory::finish()

Completes a cURL transaction, either returning a response promise or a rejected promise.

Parameters

callable $handler:

EasyHandle $easy:

CurlFactoryInterface $factory Dictates how the handle is released:

Return value

\GuzzleHttp\Promise\PromiseInterface

2 calls to CurlFactory::finish()
CurlHandler::__invoke in vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php
CurlMultiHandler::processMessages in vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php

File

vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php, line 93

Class

CurlFactory
Creates curl resources from a request

Namespace

GuzzleHttp\Handler

Code

public static function finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory) {
  if (isset($easy->options['on_stats'])) {
    self::invokeStats($easy);
  }
  if (!$easy->response || $easy->errno) {
    return self::finishError($handler, $easy, $factory);
  }

  // Return the response if it is present and there is no error.
  $factory
    ->release($easy);

  // Rewind the body of the response if possible.
  $body = $easy->response
    ->getBody();
  if ($body
    ->isSeekable()) {
    $body
      ->rewind();
  }
  return new FulfilledPromise($easy->response);
}