# How to add these headers to a xml response

**URL:** <https://www.ruby-forum.com/t/how-to-add-these-headers-to-a-xml-response/169760>\
**Category:** Rails\
**Created:** [June 8, 2009, 12:43pm UTC](https://www.ruby-forum.com/t/how-to-add-these-headers-to-a-xml-response/169760 "2009-06-08T12:43:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [June 8, 2009, 12:43pm UTC](https://www.ruby-forum.com/t/how-to-add-these-headers-to-a-xml-response/169760/1 "2009-06-08T12:43:48Z")

</div>

Hi,

I need to create something like this:

\<?xml version="1.0" encoding="UTF-8"?\> aQlfVHX+qPM 2009-09-19T08:14:55Z

The response should contain the next headers:

Content-Type=`application/vnd.3gpp+xml`  
Authentication-Info={rspauth=`xxxxxxxxxxx...xxxxxxxxxxx`,qop=`auth-int`,cnonce=`xxxxxxxxxxxxxxxxxx....xxxxxxxxxxxxx`,nc=`000 00001`}

How can I do that?

I always see {“Cache-Control”=\>“no-cache”,  
“Content-Type”=\>“application/xml”}  
when I print the headers…

I can use xml builder ok to generate the xml, but I have the problem  
with the headers.

Thanks.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [June 8, 2009, 1:02pm UTC](https://www.ruby-forum.com/t/how-to-add-these-headers-to-a-xml-response/169760/2 "2009-06-08T13:02:30Z")

</div>

On Jun 8, 11:43 am, comopasta Gr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> The response should contain the next headers:
> 
> Content-Type=`application/vnd.3gpp+xml`  
> Authentication-Info={rspauth=`xxxxxxxxxxx...xxxxxxxxxxx`,qop=`auth-int`,cno nce=`xxxxxxxxxxxxxxxxxx....xxxxxxxxxxxxx`,nc=`000 00001`}

You should just be able to set headers[‘foo’] in your controller.

Fred

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [June 8, 2009, 2:35pm UTC](https://www.ruby-forum.com/t/how-to-add-these-headers-to-a-xml-response/169760/3 "2009-06-08T14:35:36Z")

</div>

> You should just be able to set headers[‘foo’] in your controller.
> 
> Fred

Thanks Fred!  
Yeah I’ve tried several ways. Now I’ve managed to get:

{“Cache-Control”=\>“no-cache”,  
“Authentication-info”=\>“rspauth=`xxxxxxxxxxx...xxxxxxxxxxx`,qop=`auth-int`,cnonce=`xxxxxxxxxxxxxxxxxx....xxxxxxxxxxxxx`,nc=`00000001`”,  
“Content-Type”=\>“application/xml”}

I still have problems with the content-type and getting rid of  
cache-control headers.

For the content-type I’ve tried:

response.content\_type = “xxxx” and headers[‘Content-type’] = “xxxx” but  
still get always the “default” one. Haven’t yet really tried to get rid  
of the cache-control.

The response is generated like:

respond\_to do |format|  
format.xml  
end

Thanks.
