Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Converts all header names to lowercase, due node automatically converts

them

http://nodejs.org/api/http.html#http_request_headers

request.headers#
Read only map of header names and values. Header names are lower-cased.
Example:

// Prints something like:
//
// { 'user-agent': 'curl/7.22.0',
//   host: '127.0.0.1:8000',
//   accept: '*/*' }
console.log(request.headers);
  • Loading branch information...
commit ac44077d40e7a5fb95b4f4234788064eee50f672 1 parent 8de8fa9
Pablo Cantero phstc authored
Showing with 9 additions and 9 deletions.
  1. +9 −9 lib/node-static.js
18 lib/node-static.js
View
@@ -38,10 +38,10 @@ exports.Server = function (root, options) {
this.serverInfo = 'node-static/' + exports.version.join('.');
}
- this.defaultHeaders['Server'] = this.serverInfo;
+ this.defaultHeaders['server'] = this.serverInfo;
if (this.cache !== false) {
- this.defaultHeaders['Cache-Control'] = 'max-age=' + this.cache;
+ this.defaultHeaders['cache-control'] = 'max-age=' + this.cache;
}
for (var k in this.defaultHeaders) {
@@ -103,7 +103,7 @@ exports.Server.prototype.finish = function (status, headers, req, res, promise,
message: http.STATUS_CODES[status]
};
- headers['Server'] = this.serverInfo;
+ headers['server'] = this.serverInfo;
if (!status || status >= 400) {
if (callback) {
@@ -194,21 +194,21 @@ exports.Server.prototype.respond = function (pathname, status, _headers, files,
// Copy default headers
for (var k in this.options.headers) { headers[k] = this.options.headers[k] }
- headers['ETag'] = JSON.stringify([stat.ino, stat.size, mtime].join('-'));
- headers['Date'] = new(Date)().toUTCString();
- headers['Last-Modified'] = new(Date)(stat.mtime).toUTCString();
+ headers['etag'] = JSON.stringify([stat.ino, stat.size, mtime].join('-'));
+ headers['date'] = new(Date)().toUTCString();
+ headers['last-modified'] = new(Date)(stat.mtime).toUTCString();
// Conditional GET
// If the "If-Modified-Since" or "If-None-Match" headers
// match the conditions, send a 304 Not Modified.
if ((clientMTime || clientETag) &&
- (!clientETag || clientETag === headers['ETag']) &&
+ (!clientETag || clientETag === headers['etag']) &&
(!clientMTime || clientMTime >= mtime)) {
finish(304, headers);
} else {
var fileExtension = path.extname(files[0]).slice(1).toLowerCase();
- headers['Content-Length'] = stat.size;
- headers['Content-Type'] = mime.contentTypes[fileExtension] ||
+ headers['content-length'] = stat.size;
+ headers['content-type'] = mime.contentTypes[fileExtension] ||
'application/octet-stream';
for (var k in _headers) { headers[k] = _headers[k] }
Please sign in to comment.
Something went wrong with that request. Please try again.