source: trip-planner-front/node_modules/websocket-driver/lib/websocket/driver/headers.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 815 bytes
Line 
1'use strict';
2
3var Headers = function() {
4 this.clear();
5};
6
7Headers.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];
8
9Headers.prototype.clear = function() {
10 this._sent = {};
11 this._lines = [];
12};
13
14Headers.prototype.set = function(name, value) {
15 if (value === undefined) return;
16
17 name = this._strip(name);
18 value = this._strip(value);
19
20 var key = name.toLowerCase();
21 if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {
22 this._sent[key] = true;
23 this._lines.push(name + ': ' + value + '\r\n');
24 }
25};
26
27Headers.prototype.toString = function() {
28 return this._lines.join('');
29};
30
31Headers.prototype._strip = function(string) {
32 return string.toString().replace(/^ */, '').replace(/ *$/, '');
33};
34
35module.exports = Headers;
Note: See TracBrowser for help on using the repository browser.