public function __invoke(RequestInterface
$request, array
$options): PromiseInterface
{ // Sleep if there is a delay specified.
if (isset($options['delay'
])) { \
usleep($options['delay'
] * 1000
);
} $startTime =
isset($options['on_stats'
]) ? Utils::
currentTime() : null;
try { // Does not support the expect header.
$request =
$request->
withoutHeader('Expect'
);
// Append a content-length header if body size is zero to match
// cURL's behavior.
if (0 ===
$request->
getBody()->
getSize()) { $request =
$request->
withHeader('Content-Length', '0'
);
} return $this->
createResponse( $request,
$options,
$this->
createStream($request,
$options),