# Rest-client headers or cookies

**URL:** <https://www.ruby-forum.com/t/rest-client-headers-or-cookies/180564>\
**Category:** Ruby\
**Created:** [December 21, 2009, 10:49pm UTC](https://www.ruby-forum.com/t/rest-client-headers-or-cookies/180564 "2009-12-21T22:49:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ed\_Howland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Post date:** [December 21, 2009, 10:49pm UTC](https://www.ruby-forum.com/t/rest-client-headers-or-cookies/180564/1 "2009-12-21T22:49:13Z")

</div>

Hi,

I am trying to make a request to a PHP application coded with limonade  
(a REST sever like Sinatra). I’m using rest\_client which rides on top  
of Net::HTTP. I’d like to get the headers back from that call, so that  
I can store the session cookie and pass it back on subsequent  
requests.

I know how to set the headers for RestClient.get, but how do I get the  
headerts from a RestCleint.post?

Thanks,  
Ed

---

<div class="post-metadata">

**Author:** ![Ed\_Howland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Post date:** [December 22, 2009, 12:02am UTC](https://www.ruby-forum.com/t/rest-client-headers-or-cookies/180564/2 "2009-12-22T00:02:58Z")

</div>

Hi -

On Dec 21, 2009, at 10:48 PM, Ed Howland wrote:

> Hi,
> 
> I am trying to make a request to a PHP application coded with limonade  
> (a REST sever like Sinatra). I’m using rest\_client which rides on top  
> of Net::HTTP. I’d like to get the headers back from that call, so that  
> I can store the session cookie and pass it back on subsequent  
> requests.
> 
> I know how to set the headers for RestClient.get, but how do I get the  
> headerts from a RestCleint.post?

I don’t think you want the headers of the GET or POST, but of the  
response, right ?  
Did you try to assign the RestClient.get to a variable (that should be a  
Response) and call headers on it ?  
Let me know if it works.

ngw

---

<div class="post-metadata">

**Author:** ![Ed\_Howland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Post date:** [December 22, 2009, 4:22pm UTC](https://www.ruby-forum.com/t/rest-client-headers-or-cookies/180564/3 "2009-12-22T16:22:13Z")

</div>

On Mon, Dec 21, 2009 at 5:59 PM, Nicholas W.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I don’t think you want the headers of the GET or POST, but of the response, right ?  
> Did you try to assign the RestClient.get to a variable (that should be a Response) and call headers on it ?  
> Let me know if it works.
> 
> ngw

Thanks,

That did the trick. I had believed that I was just getting  
response.body from the call, but what apparently was happening was it  
was auto-casting to a string. response.to\_s is probably the same as  
response.body.

Ed
