3 var Headers = function() {
7 Headers.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];
9 Headers.prototype.clear = function() {
14 Headers.prototype.set = function(name, value) {
15 if (value === undefined) return;
17 name = this._strip(name);
18 value = this._strip(value);
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');
27 Headers.prototype.toString = function() {
28 return this._lines.join('');
31 Headers.prototype._strip = function(string) {
32 return string.toString().replace(/^ */, '').replace(/ *$/, '');
35 module.exports = Headers;