Skip to content

Commit

Permalink
Cleanup #1442
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Feb 21, 2014
1 parent f9cf927 commit 8fa375f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
7 changes: 3 additions & 4 deletions lib/response/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ exports.send = function (request, callback) {
if (response.headers.etag &&
request.headers['if-none-match'] === response.headers.etag) {

var removeKeys = ['content-length', 'etag', 'last-modified'];
Utils.removeKeys(response.headers, removeKeys);
response.statusCode = 304;
}
else {
Expand All @@ -150,8 +148,6 @@ exports.send = function (request, callback) {
lastModified &&
ifModifiedSince >= lastModified) {

var removeKeys = ['content-length', 'etag', 'last-modified'];
Utils.removeKeys(response.headers, removeKeys);
response.statusCode = 304;
}
}
Expand Down Expand Up @@ -213,6 +209,9 @@ internals.transmit = function (response, request, callback) {
}
else {
source = new internals.Empty();
delete response.headers['content-length'];
delete response.headers['etag'];
delete response.headers['last-modified'];
}

// Close unused file streams
Expand Down
8 changes: 0 additions & 8 deletions test/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,19 +1127,15 @@ describe('Response', function () {
var etag1 = res2.headers.etag;

expect(etag1.slice(0, 1)).to.equal('"');

expect(etag1.slice(-1)).to.equal('"');

// etag

server.inject({ url: '/note', headers: { 'if-none-match': etag1 } }, function (res3) {

expect(res3.statusCode).to.equal(304);

expect(res3.headers).to.not.have.property('content-length');

expect(res3.headers).to.not.have.property('etag');

expect(res3.headers).to.not.have.property('last-modified');

var fd = Fs.openSync(__dirname + '/file/note.txt', 'w');
Expand Down Expand Up @@ -1232,13 +1228,9 @@ describe('Response', function () {
server.inject({ url: '/file', headers: { 'if-modified-since': res1.headers.date } }, function (res2) {

expect(res2.statusCode).to.equal(304);

expect(res2.headers).to.not.have.property('content-length');

expect(res2.headers).to.not.have.property('etag');

expect(res2.headers).to.not.have.property('last-modified');

done();
});
});
Expand Down

0 comments on commit 8fa375f

Please sign in to comment.