mikeal/request — Issue #140: Cookie issue with uppercase names
Author: cmichi
Created: 2011-12-25 10:27:41+00:00
State: open

I found an issue in [vendor/cookie/index.js](https://github.com/mikeal/request/blob/master/vendor/cookie/index.js):

```javascript
// First key is the name
this.name = str.substr(0, str.indexOf('='));

// Map the key/val pairs
str.split(/ *; */).reduce(function(obj, pair){
pair = pair.split(/ *= */);
obj[pair[0].toLowerCase()] = pair[1] || true;
return obj;
}, this);

// Assign value
this.value = this[this.name];
```

Commit [b2a4ad1e7d](https://github.com/mikeal/request/commit/b2a4ad1e7d7553230e932ea093d7f77f38147ef9) is noted "Force all cookie keys into lower case as suggested by LinusU". I don't understand why this is necessary. It introduces a bug since ```this.name = str.substr(0, str.indexOf('='));``` is not assigned a lowercase string. This results in ```this.value = this[this.name];``` assigning ```undefined``` in cases where "Set-Cookie" for example is "ES=4da3d6b4c946b189".

I don't see why ```.toLowerCase()``` originally was introduced, but from my point of view I think it can safely be removed.