# Removing http headers

**URL:** <https://www.ruby-forum.com/t/removing-http-headers/117987>\
**Category:** Rails\
**Created:** [October 23, 2007, 12:58am UTC](https://www.ruby-forum.com/t/removing-http-headers/117987 "2007-10-23T00:58:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gepetto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f19dbf/32.png) [@gepetto](https://www.ruby-forum.com/u/gepetto)\
**Post date:** [October 23, 2007, 12:58am UTC](https://www.ruby-forum.com/t/removing-http-headers/117987/1 "2007-10-23T00:58:10Z")

</div>

Hi All,

I hope you can help me, I need to remove the http headers an action  
sends as response, and haven’t been able to find how.

A normal http response would have the following headers:

Cache-Control no-cache  
Connection Keep-Alive  
Date Mon, 22 Oct 2007 19:47:01 GMT  
Content-Type text/html; charset=utf-8; charset=utf-8  
Server WEBrick/1.3.1 (Ruby/1.8.6/2007-03-13)  
Content-Length 1  
Set-Cookie _first\_session_

If I add the line “@headers.clear” to the action, the Cache-Control  
header dissapears:

Connection Keep-Alive  
Date Mon, 22 Oct 2007 19:47:28 GMT  
Content-Type text/html; charset=utf-8  
Server WEBrick/1.3.1 (Ruby/1.8.6/2007-03-13)  
Content-Length 1  
Set-Cookie \_first\_session\_id=fc6285470aa256fbcedad6ad200eb437; path=/

I also found that by disabling the session with “session :disabled =\>  
true” the Set-Cookie header is not sent:

Connection Keep-Alive  
Date Mon, 22 Oct 2007 22:25:10 GMT  
Content-Type text/html; charset=iso-8859-1  
Server WEBrick/1.3.1 (Ruby/1.8.6/2007-03-13)  
Content-Length 1

Now I need to remove the “Server”, “Date”, “Connection” and  
“Content-Type” header.

The reason I am doing this is that I need to save as much bytes as  
possible, as this request will be sent in a mobile environment, and each  
byte sent is “expensive”. I am also in control of the client making the  
request, so there won’t be trouble reading the answer.

Any clues?

Thank you,  
Gepetto
