test undefined Accept-Encoding with head request

caching-middleware-duplicate-compress
webzwo0i 2020-12-23 15:41:07 +01:00
parent 04bb2a9f8f
commit a4639fa638
1 changed files with 20 additions and 4 deletions

View File

@ -76,9 +76,18 @@ describe(__filename, function () {
assert.match(res.header['content-type'], /application\/javascript/);
assert.equal(res.header['content-encoding'], undefined);
assert.equal(isPlaintextResponse(res.text, resource), true);
return;
})));
});
// need to use head here - cant unset Accept-Encoding in GET requests
it('head request without Accept-Encoding header does not set Content-Encoding', async function () {
await agent
.head(packages[0])
.then((res) => {
assert.match(res.header['content-type'], /application\/javascript/);
assert.equal(res.header['content-encoding'], undefined);
});
});
it('gets packages compressed with Accept-Encoding gzip', async function () {
await Promise.all(packages.map(async (resource) => await agent.get(resource)
@ -88,7 +97,6 @@ describe(__filename, function () {
assert.match(res.header['content-type'], /application\/javascript/);
assert.equal(res.header['content-encoding'], 'gzip');
assert.equal(isPlaintextResponse(res.text, resource), false);
return;
})));
});
@ -126,10 +134,19 @@ describe(__filename, function () {
assert.match(res.header['content-type'], /application\/javascript/);
assert.equal(res.header['content-encoding'], undefined);
assert.equal(isPlaintextResponse(res.text, resource), true);
return;
})));
});
// need to use head here - cant unset Accept-Encoding in GET requests
it('head request without Accept-Encoding header does not set Content-Encoding', async function () {
await agent
.head(packages[0])
.then((res) => {
assert.match(res.header['content-type'], /application\/javascript/);
assert.equal(res.header['content-encoding'], undefined);
});
});
it('gets packages compressed with Accept-Encoding gzip', async function () {
await Promise.all(packages.map(async (resource) => await agent.get(resource)
.set('Accept-Encoding', 'gzip')
@ -138,7 +155,6 @@ describe(__filename, function () {
assert.match(res.header['content-type'], /application\/javascript/);
assert.equal(res.header['content-encoding'], 'gzip');
assert.equal(isPlaintextResponse(res.text, resource), false);
return;
})));
});