Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
NinaFan0824 committed Feb 21, 2024
1 parent c6bda20 commit adfc8e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ts-force/src/rest/restHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export type RequestHeadersInput = {
'If-None-Match'?: string[];
};

export const GetOrHeadRequestHeaders = ['If-Match', 'If-None-Match', 'If-Modified-Since'];
export const PatchOrPostRequestHeaders = ['If-Match', 'If-None-Match', 'If-Unmodified-Since'];
export const GetOrHeadRequestHeaders: (keyof RequestHeadersInput)[] = ['If-Match', 'If-None-Match', 'If-Modified-Since'];
export const PatchOrPostRequestHeaders: (keyof RequestHeadersInput)[] = ['If-Match', 'If-None-Match', 'If-Unmodified-Since'];
8 changes: 6 additions & 2 deletions ts-force/src/rest/restObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ export abstract class RestObject extends SObject {
);

// Check if it contains Conditional Request Headers and deal with errors
const containsGetOrHeadHeader = Object.keys(opts.headers).some((key) => GetOrHeadRequestHeaders.includes(key));
const containsPatchOrPostHeader = Object.keys(opts.headers).some((key) => PatchOrPostRequestHeaders.includes(key));
const containsGetOrHeadHeader = Object.keys(opts.headers).some((key) =>
GetOrHeadRequestHeaders.includes(key as keyof RequestHeadersInput)
);
const containsPatchOrPostHeader = Object.keys(opts.headers).some((key) =>
PatchOrPostRequestHeaders.includes(key as keyof RequestHeadersInput)
);
if (containsGetOrHeadHeader && response.status === 304) {
throw new Error('Not Modified');
} else if (containsPatchOrPostHeader && response.status === 412) {
Expand Down

0 comments on commit adfc8e4

Please sign in to comment.