Sha256: 0a0bc538c07b6eac65594230f495a4e926291ef77901681d317116afe80fa0b5

Contents?: true

Size: 815 Bytes

Versions: 49

Compression:

Stored size: 815 Bytes

Contents

'use strict';

var Headers = function() {
  this.clear();
};

Headers.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];

Headers.prototype.clear = function() {
  this._sent  = {};
  this._lines = [];
};

Headers.prototype.set = function(name, value) {
  if (value === undefined) return;

  name = this._strip(name);
  value = this._strip(value);

  var key = name.toLowerCase();
  if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {
    this._sent[key] = true;
    this._lines.push(name + ': ' + value + '\r\n');
  }
};

Headers.prototype.toString = function() {
  return this._lines.join('');
};

Headers.prototype._strip = function(string) {
  return string.toString().replace(/^ */, '').replace(/ *$/, '');
};

module.exports = Headers;

Version data entries

49 entries across 37 versions & 14 rubygems

Version Path
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/websocket-driver/lib/websocket/driver/headers.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/websocket-driver/lib/websocket/driver/headers.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/websocket-driver/lib/websocket/driver/headers.js
tang-0.2.0 spec/tang_app/node_modules/sockjs/node_modules/websocket-driver/lib/websocket/driver/headers.js
tang-0.2.0 spec/tang_app/node_modules/websocket-driver/lib/websocket/driver/headers.js
tang-0.1.0 spec/tang_app/node_modules/websocket-driver/lib/websocket/driver/headers.js
tang-0.1.0 spec/tang_app/node_modules/sockjs/node_modules/websocket-driver/lib/websocket/driver/headers.js
tang-0.0.9 spec/tang_app/node_modules/websocket-driver/lib/websocket/driver/headers.js
tang-0.0.9 spec/tang_app/node_modules/sockjs/node_modules/websocket-driver/lib/websocket/driver/headers.js
enju_library-0.3.8 spec/dummy/node_modules/websocket-driver/lib/websocket/driver/headers.js
ilog-0.4.1 node_modules/websocket-driver/lib/websocket/driver/headers.js
ilog-0.4.0 node_modules/websocket-driver/lib/websocket/driver/headers.js
ilog-0.3.3 node_modules/websocket-driver/lib/websocket/driver/headers.js
jester-data-8.0.0 node_modules/websocket-driver/lib/websocket/driver/headers.js
ezii-os-5.2.1 node_modules/websocket-driver/lib/websocket/driver/headers.js
ezii-os-2.0.1 node_modules/websocket-driver/lib/websocket/driver/headers.js
ezii-os-1.1.0 node_modules/websocket-driver/lib/websocket/driver/headers.js
ezii-os-1.0.0 node_modules/websocket-driver/lib/websocket/driver/headers.js
ezii-os-0.0.0.1.0 node_modules/websocket-driver/lib/websocket/driver/headers.js
ezii-os-0.0.0.0.1 node_modules/websocket-driver/lib/websocket/driver/headers.js