[Pkg-javascript-commits] [node-mocks-http] 208/296: somewhere in the guts of the sendstream pipe calls (in "fresh"), it directly checks response._headers.

Thorsten Alteholz alteholz at moszumanska.debian.org
Mon Feb 8 18:13:37 UTC 2016


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

alteholz pushed a commit to branch master
in repository node-mocks-http.

commit d2d67322b22fe51516c181e3884811ddf40afee3
Author: Jason Loveman <jloveman at qca.qualcomm.com>
Date:   Thu Apr 9 13:33:42 2015 -0700

    somewhere in the guts of the sendstream pipe calls (in "fresh"),
    it directly checks response._headers.
    
    Signed-off-by: Jason Loveman <jloveman at qca.qualcomm.com>
---
 lib/mockResponse.js | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/mockResponse.js b/lib/mockResponse.js
index d288cc4..eacc555 100644
--- a/lib/mockResponse.js
+++ b/lib/mockResponse.js
@@ -38,7 +38,6 @@ function createResponse(options) {
 
     var _endCalled = false;
     var _data = '';
-    var _headers = {};
     var _encoding = options.encoding;
 
     var _redirectUrl = '';
@@ -58,6 +57,8 @@ function createResponse(options) {
 
     var mockResponse = {};
 
+    mockResponse._headers = {};
+
     mockResponse.statusCode = 200;
     mockResponse.cookies = {};
 
@@ -101,9 +102,9 @@ function createResponse(options) {
         // Note: Not sure if the headers given in this function
         //       overwrite any headers specified earlier.
         if (headers) {
-            _headers = headers;
+            mockResponse._headers = headers;
         } else {
-            _headers = phrase;
+            mockResponse._headers = phrase;
         }
 
     };
@@ -169,7 +170,7 @@ function createResponse(options) {
             case 3:
 
                 _formatData(a);
-                _headers = b;
+                mockResponse._headers = b;
                 mockResponse.statusCode = c;
                 console.warn('WARNING: Called send() with deprecated three parameters');
 
@@ -353,7 +354,7 @@ function createResponse(options) {
      *   Returns a particular header by name.
      */
     mockResponse.get = mockResponse.getHeader = function(name) {
-        return _headers[name];
+        return mockResponse._headers[name];
     };
 
     /**
@@ -363,7 +364,7 @@ function createResponse(options) {
      *   Set a particular header by name.
      */
     mockResponse.setHeader = function(name, value) {
-        _headers[name] = value;
+        mockResponse._headers[name] = value;
         return value;
     };
 
@@ -373,7 +374,7 @@ function createResponse(options) {
      *   Removes an HTTP header by name.
      */
     mockResponse.removeHeader = function(name) {
-        delete _headers[name];
+        delete mockResponse._headers[name];
     };
 
     /**
@@ -515,7 +516,7 @@ function createResponse(options) {
      *  empty object, but probably will have "Content-Type" set.
      */
     mockResponse._getHeaders = function() {
-        return _headers;
+        return mockResponse._headers;
     };
 
     /**
@@ -543,7 +544,7 @@ function createResponse(options) {
      *  It doesn't validate the data that was sent.
      */
     mockResponse._isJSON = function() {
-        return (_headers['Content-Type'] === 'application/json');
+        return (mockResponse._headers['Content-Type'] === 'application/json');
     };
 
     /**
@@ -580,8 +581,8 @@ function createResponse(options) {
      */
     mockResponse._isDataLengthValid = function() {
 
-        if (_headers['Content-Length']) {
-            return (_headers['Content-Length'].toString() === _data.length.toString());
+        if (mockResponse._headers['Content-Length']) {
+            return (mockResponse._headers['Content-Length'].toString() === _data.length.toString());
         }
 
         return true;

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



More information about the Pkg-javascript-commits mailing list