Set event stream reconnect time from Retry-After header

This commit is contained in:
Samuel Elliott 2023-07-26 10:10:20 +01:00
parent 69afbc6d69
commit 2cbfdc5e04
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6

View File

@ -168,6 +168,12 @@ export default class EventSource {
this._response = response;
this._connecting = null;
const retry_after = response.headers.get('Retry-After');
if (retry_after && /^\d+$/.test(retry_after)) {
this._retry_after = parseInt(retry_after);
}
if (!response.ok) {
const error = await EventSourceErrorResponse.fromResponse(response, 'Non-200 status code');
return this._handleResponseError(response, controller, error);