/
lostSun
/
project-client-server-apps
Обзор
Документация
Войти
/
lostSun
/
project-client-server-apps
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/websocket-driver/lib/websocket/driver/headers.js
35 строк
815 B
1lostsun
initial commit
05 май 2025, 11:35
05 май 2025, 11:35
fe8f535
Код
Авторство
О чём код?
'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;