Skip to content

Commit 7d305d3

Browse files
authored
Merge pull request #228 from wolfpackthatcodes/fix/-typescript-S6582
2 parents ea808b0 + c3a85bf commit 7d305d3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

code/src/http/httpClient.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,21 @@ export default class HttpClient {
331331
return this.sendRequest('HEAD');
332332
}
333333

334+
/**
335+
* Determine if response is successful.
336+
*
337+
* @param {Response} response
338+
*
339+
* @returns {boolean}
340+
*/
341+
private isSuccessfulResponse(response?: Response): boolean {
342+
if (response === undefined) {
343+
return false;
344+
}
345+
346+
return response.ok;
347+
}
348+
334349
/**
335350
* Process a OPTIONS request to the given URL.
336351
*
@@ -490,7 +505,7 @@ export default class HttpClient {
490505

491506
try {
492507
const response: Response = await this.attemptRequest(method);
493-
const successfulResponse: boolean = response !== undefined && response.ok;
508+
const successfulResponse: boolean = this.isSuccessfulResponse(response);
494509
const shouldRetry = this.retryCallback ? this.retryCallback(response, this) : true;
495510

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

0 commit comments

Comments
 (0)