Skip to content

fix: handle HTTP 304 response status code #4510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/common/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the check responseData.statusCode === HttpStatusCodes.NOT_MODIFIED should be inside isRequestSuccessful function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've considered this option, but I'm not sure if it is applicable for everyone who would use isRequestSuccessful helper method. By definition only requests between 200 and 300 are success, so it will seem strange to handle 304 inside that method

if (!successful) {
pipeTo = undefined;
}
Expand Down