Skip to content

Commit

Permalink
Revert "fix(http): exclude caching for authenticated HTTP requests (#…
Browse files Browse the repository at this point in the history
…54746)" (#55033)

This reverts commit 2258ac7.

Closes: #55031

PR Close #55033
  • Loading branch information
alan-agius4 authored and dylhunn committed Mar 26, 2024
1 parent 4bb332e commit 8958e0b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
5 changes: 1 addition & 4 deletions packages/common/http/src/transfer_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ export function transferCacheInterceptorFn(
// POST requests are allowed either globally or at request level
(requestMethod === 'POST' && !globalOptions.includePostRequests && !requestOptions) ||
(requestMethod !== 'POST' && !ALLOWED_METHODS.includes(requestMethod)) ||
// Do not cache request that require authorization
req.headers.has('authorization') ||
req.headers.has('proxy-authorization') ||
requestOptions === false ||
requestOptions === false || //
globalOptions.filter?.(req) === false
) {
return next(req);
Expand Down
16 changes: 0 additions & 16 deletions packages/common/http/test/transfer_cache_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,6 @@ describe('TransferCache', () => {
makeRequestAndExpectNone('/test-2?foo=1', 'POST', {transferCache: true});
});

it('should not cache request that requires authorization', async () => {
makeRequestAndExpectOne('/test-auth', 'foo', {
headers: {Authorization: 'Basic YWxhZGRpbjpvcGVuc2VzYW1l'},
});

makeRequestAndExpectOne('/test-auth', 'foo');
});

it('should not cache request that requires proxy authorization', async () => {
makeRequestAndExpectOne('/test-auth', 'foo', {
headers: {'Proxy-Authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l'},
});

makeRequestAndExpectOne('/test-auth', 'foo');
});

it('should cache POST with the differing body in string form', () => {
makeRequestAndExpectOne('/test-1', null, {method: 'POST', transferCache: true, body: 'foo'});
makeRequestAndExpectNone('/test-1', 'POST', {transferCache: true, body: 'foo'});
Expand Down

0 comments on commit 8958e0b

Please sign in to comment.