From e24d92b9a5b1e6442a06fdad5b5cf85e95f4382e Mon Sep 17 00:00:00 2001 From: Alexis Georges Date: Mon, 10 May 2021 13:04:37 +0200 Subject: [PATCH] fix(stark-core): add support for http 204 status code when persisting logs As Stark does not use returned body when persisting logs, there is no need to force the backend to send a 201 status code. The 204 status code should be accepted when no content is received. --- .../modules/logging/services/logging.service.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/stark-core/src/modules/logging/services/logging.service.ts b/packages/stark-core/src/modules/logging/services/logging.service.ts index def3304613..e5c3a42a90 100644 --- a/packages/stark-core/src/modules/logging/services/logging.service.ts +++ b/packages/stark-core/src/modules/logging/services/logging.service.ts @@ -183,11 +183,15 @@ export class StarkLoggingServiceImpl implements StarkLoggingService { const emitXhrResult = (xhrRequest: XMLHttpRequest): void => { if (xhrRequest.readyState === XMLHttpRequest.DONE) { - if (xhrRequest.status === StarkHttpStatusCodes.HTTP_200_OK || xhrRequest.status === StarkHttpStatusCodes.HTTP_201_CREATED) { - httpRequest$.next(); - httpRequest$.complete(); - } else { - httpRequest$.error(xhrRequest.status); + switch (xhrRequest.status) { + case StarkHttpStatusCodes.HTTP_200_OK: + case StarkHttpStatusCodes.HTTP_201_CREATED: + case StarkHttpStatusCodes.HTTP_204_NO_CONTENT: + httpRequest$.next(); + httpRequest$.complete(); + break; + default: + httpRequest$.error(xhrRequest.status); } } };