# Net::HTTP header issue

**URL:** <https://www.ruby-forum.com/t/net-http-header-issue/120279>\
**Category:** Ruby\
**Created:** [November 15, 2007, 2:36pm UTC](https://www.ruby-forum.com/t/net-http-header-issue/120279 "2007-11-15T14:36:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![el2king](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f08c70/32.png) [@el2king](https://www.ruby-forum.com/u/el2king)\
**Post date:** [November 15, 2007, 2:36pm UTC](https://www.ruby-forum.com/t/net-http-header-issue/120279/1 "2007-11-15T14:36:13Z")

</div>

I am trying to use custom headers, and I am having an issue with how  
Net::HTTP handles this. Let’s say I want to add the header “a-header”  
to the HTTP message I am sending to a server. When I turn on a TCP  
monitor to check on the message, I notice that Net::HTTP changes  
“a-header” to “A-Header”. I would like to prevent Net::HTTP from  
changing the casing of my header, but I would also like to avoid  
modifying the Net::HTTP library to do this. Is there a solution to  
prevent Net::HTTP from changing the casing of “a-header” without  
modifying the Net::HTTP library (like a function in that library to call  
to stop the casing change)? If not, what is the cleanest solution to  
modify Net::HTTP for this issue? Thanks!

---

<div class="post-metadata">

**Author:** ![el2king](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f08c70/32.png) [@el2king](https://www.ruby-forum.com/u/el2king)\
**Post date:** [November 15, 2007, 9:45pm UTC](https://www.ruby-forum.com/t/net-http-header-issue/120279/2 "2007-11-15T21:45:53Z")

</div>

On Nov 15, 2007 5:36 AM, Edward L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am trying to use custom headers, and I am having an issue with how  
> Net::HTTP handles this. Let’s say I want to add the header “a-header”  
> to the HTTP message I am sending to a server. When I turn on a TCP  
> monitor to check on the message, I notice that Net::HTTP changes  
> “a-header” to “A-Header”. I would like to prevent Net::HTTP from  
> changing the casing of my header

“”""4.2 Message Headers

HTTP header fields, which include general-header (section 4.5),  
request-header (section 5.3), response-header (section 6.2), and  
entity-header (section 7.1) fields, follow the same generic format as  
that given in Section 3.1 of RFC 822 [9]. Each header field consists  
of a name followed by a colon (“:”) and the field value. Field names  
\_\__ **are case-insensitive** _.“”"

[http://www.ietf.org/rfc/rfc2616.txt](http://www.ietf.org/rfc/rfc2616.txt)

HTH,  
Keith

---

<div class="post-metadata">

**Author:** ![el2king](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f08c70/32.png) [@el2king](https://www.ruby-forum.com/u/el2king)\
**Post date:** [November 15, 2007, 9:52pm UTC](https://www.ruby-forum.com/t/net-http-header-issue/120279/3 "2007-11-15T21:52:04Z")

</div>

This doesn’t help me at all. I already know that field names are  
case-insensitive. However, when my web server receives an HTTP message,  
it will see my custom header of “a-header” as “A-Header” because of  
Net::HTTP. I don’t really want Net::HTTP to modify my header contents  
(I might want to be able to send “A-HEADER” and not have Net::HTTP  
change it to “A-Header”), so that’s why I posted. Your response isn’t  
really what I am looking for. Does anyone have an answer for my initial  
post? Thanks!

Keith F. wrote:

> On Nov 15, 2007 5:36 AM, Edward L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I am trying to use custom headers, and I am having an issue with how  
> > Net::HTTP handles this. Let’s say I want to add the header “a-header”  
> > to the HTTP message I am sending to a server. When I turn on a TCP  
> > monitor to check on the message, I notice that Net::HTTP changes  
> > “a-header” to “A-Header”. I would like to prevent Net::HTTP from  
> > changing the casing of my header
> 
> “”""4.2 Message Headers
> 
> HTTP header fields, which include general-header (section 4.5),  
> request-header (section 5.3), response-header (section 6.2), and  
> entity-header (section 7.1) fields, follow the same generic format as  
> that given in Section 3.1 of RFC 822 [9]. Each header field consists  
> of a name followed by a colon (“:”) and the field value. Field names  
> \_\__ **are case-insensitive** _.“”"
> 
> [http://www.ietf.org/rfc/rfc2616.txt](http://www.ietf.org/rfc/rfc2616.txt)
> 
> HTH,  
> Keith

---

<div class="post-metadata">

**Author:** ![el2king](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f08c70/32.png) [@el2king](https://www.ruby-forum.com/u/el2king)\
**Post date:** [November 16, 2007, 4:45am UTC](https://www.ruby-forum.com/t/net-http-header-issue/120279/4 "2007-11-16T04:45:44Z")

</div>

On Nov 15, 2007, at 6:36 AM, Edward L. wrote:

> ## to stop the casing change)? If not, what is the cleanest solution to modify Net::HTTP for this issue? Thanks!
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

you can try something like

class CaseSensitiveHeader \< ::String  
def capitalize() self end  
end

add\_header CaseSensitiveHeader.new(‘a-header’), value

or

module Net  
module HTTPHeader  
def capitalize(name) name end  
end  
end

just took a quick look at the net/http.rb, but one of them will work.

a @ [http://codeforpeople.com/](http://codeforpeople.com/)
