So, in that bit of code, if you do setHeader('x-FoO', 'baR'), then:

    this._headers['x-foo'] === 'baR'
    this._headerNames['x-foo'] === 'x-FoO'

Later, when it actually writes the header lines, it writes:

    this._headerNames['x-foo'] + ': ' + this._headers['x-foo'] + '\r\n'

or in other words:

    'x-FoO: baR\r\n'

just like you asked it to.

This code is about the outgoing headers that *your app* sends out.
(Ie, the HTTP response in a Server, or the HTTP request in a Client.)


Without theories about *why* it is, can you you clarify what you're
actually having problems with?

1. My node http server is sending lowercased headers in the response.
2. My node http server is receiving lowercased headers in the request.
3. My node http client is sending lowercased headers in the request.
4. My node http client is receiving lowercased headers in the response.





On Sat, Dec 1, 2012 at 8:04 PM, Cristian Bullokles
<[email protected]> wrote:
> Debugging my code with node-inspector I found the code below.
> The problem is in line:
>   var key = name.toLowerCase();
>
> What is the value added of lowercase headers in outgoing messages?
>
> Regards
> Cristian
>
> File: http.js
> Line 639 to 653
>
> OutgoingMessage.prototype.setHeader = function(name, value) {
>   if (arguments.length < 2) {
>     throw new Error('`name` and `value` are required for setHeader().');
>   }
>
>   if (this._header) {
>     throw new Error('Can\'t set headers after they are sent.');
>   }
>
>   var key = name.toLowerCase();
>   this._headers = this._headers || {};
>   this._headerNames = this._headerNames || {};
>   this._headers[key] = value;
>   this._headerNames[key] = name;
> };
>
> On Sun, Dec 2, 2012 at 12:04 AM, Ben Noordhuis <[email protected]> wrote:
>>
>> On Sun, Dec 2, 2012 at 3:53 AM, Mikeal Rogers <[email protected]>
>> wrote:
>> > headers core sets, like transfer-encoding and host will be lowercase.
>>
>> Wrong again.  Auto-added headers like Authorization, Date,
>> Content-Length, Transfer-Encoding, etc. are all properly capitalized.
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to