private function onCryptoCompletion(RequestCycle $cycle)
{
$parser = new Parser(Parser::MODE_RESPONSE);
$parser->enqueueResponseMethodMatch($cycle->request->getMethod());
$parser->setAllOptions([Parser::OP_DISCARD_BODY => $cycle->options[self::OP_DISCARD_BODY], Parser::OP_RETURN_BEFORE_ENTITY => true, Parser::OP_BODY_DATA_CALLBACK => function ($data) use($cycle) {
$cycle->futureResponse->update([Notify::RESPONSE_BODY_DATA, $data]);
}]);
$cycle->parser = $parser;
$cycle->readWatcher = $this->reactor->onReadable($cycle->socket, function () use($cycle) {
$this->onReadableSocket($cycle);
});
$timeout = $cycle->options[self::OP_MS_TRANSFER_TIMEOUT];
if ($timeout > 0) {
$cycle->transferTimeoutWatcher = $this->reactor->once(function () use($cycle, $timeout) {
$this->fail($cycle, new TimeoutException(sprintf('Allowed transfer timeout exceeded: %d ms', $timeout)));
}, $timeout);
}
$this->writeRequest($cycle);
}