if (null ===
$state->buffer
|| ($isTimeout &&
hrtime(true
) / 1E9 -
$state->lastError <
$state->reconnectionTime
)) { yield $chunk;
} else { $options['headers'
]['Last-Event-ID'
] =
$state->lastEventId;
$state->buffer = '';
$state->lastError =
hrtime(true
) / 1E9;
$context->
getResponse()->
cancel();
$context->
replaceRequest($method,
$url,
$options);
if ($isTimeout) { yield $chunk;
} else { $context->
pause($state->reconnectionTime
);
} } return;
} if ($chunk->
isFirst()) { if (preg_match('/^text\/event-stream(;|$)/i',
$context->
getHeaders()['content-type'
][0
] ?? ''
)) { $state->buffer = '';
} elseif (null !==
$lastError || (null !==
$state->buffer && 200 ===
$context->
getStatusCode())) { throw new EventSourceException(sprintf('Response content-type is "%s" while "text/event-stream" was expected for "%s".',
$context->
getHeaders()['content-type'
][0
] ?? '',
$context->
getInfo('url'
)));
}