[Pkg-javascript-commits] [node-static] 85/151: Converts all header names to lowercase, due node automatically converts them

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:00 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository node-static.

commit ac44077d40e7a5fb95b4f4234788064eee50f672
Author: Pablo Cantero <pablo at pablocantero.com>
Date:   Sat Oct 13 14:50:11 2012 -0300

    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);
---
 lib/node-static.js | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 468ed9c..a3453e1 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -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] }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git



More information about the Pkg-javascript-commits mailing list