Skip to content
Merged
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
17 changes: 16 additions & 1 deletion code/src/http/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@ export default class HttpClient {
return this.sendRequest('HEAD');
}

/**
* Determine if response is successful.
*
* @param {Response} response
*
* @returns {boolean}
*/
private isSuccessfulResponse(response?: Response): boolean {
if (response === undefined) {
return false;
}

return response.ok;
}

/**
* Process a OPTIONS request to the given URL.
*
Expand Down Expand Up @@ -490,7 +505,7 @@ export default class HttpClient {

try {
const response: Response = await this.attemptRequest(method);
const successfulResponse: boolean = response !== undefined && response.ok;
const successfulResponse: boolean = this.isSuccessfulResponse(response);
const shouldRetry = this.retryCallback ? this.retryCallback(response, this) : true;

if (!successfulResponse && shouldRetry === true && this.requestAttempts <= this.retries) {
Expand Down