Check for Host header should be case-insensitive #406

Closed
avik-das opened this Issue Jan 4, 2013 · 5 comments

3 participants

@avik-das

Currently, request checks that if the 'Host' header is present in the options but only checks the lowercase version: https://github.com/mikeal/request/blob/b85bf633fe8197dc38855f10016a0a76a8ab600a/main.js#L187

What I see is that I can't set the 'Host' header with capitalization because it is ultimately overwritten by 'host'. I would like to, for the sake of agreement with standard protocol , set 'Host' instead of 'host', but I'm unable to. Can the check on the line I linked to be made case-insensitive? I can provide a patch if necessary.

Ideally, I'd love for the header that request sets itself to also be capitalized so that I don't have to override the capitalization, but at least the check should be case-insensitive.

@jspilman

See also #411

@mikeal
request member

we need either a getHeader or headerExists method that is caseless. I think the ideal API is

r.getHeader('HoSt') // returns value or undefined

If you want to find the casing yourself you can just iterate over the headers object.

@avik-das

I see getHeader on line 815 already (though it also takes as input the headers object), so the check for 'Host' should be using that as far as I can tell.

@mikeal
request member

fixed.

@mikeal mikeal closed this Aug 27, 2014
@avik-das

Thanks @mikeal !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment