From 9bce91f37dada0ea889d408c703bc13675643ad2 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 8 Apr 2019 09:55:51 +0300 Subject: [PATCH] fix: handle HTTP 304 response status code In case 304 is returned, the cached version of the result should be used, so consider this response as success. NOTE: It can be returned only when specific header is sent in the request, so the caller actually expects to receive either 304 or 200 with new content. --- lib/common/constants.ts | 1 + lib/common/http-client.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/common/constants.ts b/lib/common/constants.ts index 285a33df5d..699647df64 100644 --- a/lib/common/constants.ts +++ b/lib/common/constants.ts @@ -92,6 +92,7 @@ export class Proxy { */ export class HttpStatusCodes { static SEE_OTHER = 303; + static NOT_MODIFIED = 304; static PAYMENT_REQUIRED = 402; static PROXY_AUTHENTICATION_REQUIRED = 407; } diff --git a/lib/common/http-client.ts b/lib/common/http-client.ts index 902be6e9c7..9d4db22847 100644 --- a/lib/common/http-client.ts +++ b/lib/common/http-client.ts @@ -168,7 +168,7 @@ export class HttpClient implements Server.IHttpClient { this.setResponseResult(promiseActions, cleanupRequestData, { err: new Error(HttpClient.STUCK_RESPONSE_ERROR_MESSAGE) }); } }, HttpClient.STUCK_RESPONSE_CHECK_INTERVAL); - const successful = helpers.isRequestSuccessful(responseData); + const successful = helpers.isRequestSuccessful(responseData) || responseData.statusCode === HttpStatusCodes.NOT_MODIFIED; if (!successful) { pipeTo = undefined; }