Forum: Ruby on Rails Remove Http header response

5b9dffc647cd2ca8a8a1487846ec6ad9?d=identicon&s=25 Tok L. (tok_l)
on 2014-06-18 07:38
Hi

I am working on a project which requires a client to make an api call to
my
rails application and it to return XML without any http header info.

its currently returning:

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Type: application/xml; charset=
X-Ua-Compatible: IE=Edge
X-Request-Id: c5602cd7eb23ca8137bef8bb1f0a4f8a
X-Runtime: 0.027900
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-11-22)
Date: Wed, 18 Jun 2014 05:27:48 GMT
Content-Length: 529
Connection: Keep-Alive
Set-Cookie: _session_id=a8039d615674feec206e6c55a7a7afc8; path=/;
HttpOnly

<?xml version="1.0" encoding="UTF-8"?>
<cXML>
  <Response>
    <Status code="200" text="OK"/>
      <StartPage>
    <URL>http://localhost:3000/foobar/BAh7DDoNYmFza2V0aWRJI...
      </StartPage>
  </Response>
</cXML>



Can anyone help to remove the http headers within the controller or any
config?

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Type: application/xml; charset=
X-Ua-Compatible: IE=Edge
X-Request-Id: c5602cd7eb23ca8137bef8bb1f0a4f8a
X-Runtime: 0.027900
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-11-22)
Date: Wed, 18 Jun 2014 05:27:48 GMT
Content-Length: 529
Connection: Keep-Alive
Set-Cookie: _session_id=a8039d615674feec206e6c55a7a7afc8; path=/;
HttpOnly



Thanks in advance.



T
Dfc7587fd73f2efa19d6f1f9611b70ba?d=identicon&s=25 Jason Fb (jasonfb)
on 2014-06-18 17:07
(Received via mailing list)
For and XML response the header should be Content-type: text/xml

Generally all you need to do is pass format to the render block, or use
respond_with. Alternatively, you should be able to pass content_type as
a parameter to the render block.

But perhaps you meant you want to remove all the headers from the
response? This is kind of a nonsense request, since HTTP servers by
definition uses header to talk to one another.

That's basically like asking to have a phone call with someone but not
have the phone company use satellites or copper wires during the
conversion.

What client-side application could you possibly be using to accept
responses without any HTTP headers at all ?
50d9a1c52e39ca209b5ab3386d0176bc?d=identicon&s=25 Jay Dee (ftumsh)
on 2014-06-24 18:30
You may think it is nonsense, W3 think otherwise. Perhaps you should
inform them of their nonsense?

http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4

"message consist of a start-line, *zero* or more header fields"
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-24 20:16
(Received via mailing list)
On 24 June 2014 17:30, Jay Dee <lists@ruby-forum.com> wrote:
> You may think it is nonsense, W3 think otherwise. Perhaps you should
> inform them of their nonsense?
>
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4
>
> "message consist of a start-line, *zero* or more header fields"
>

Since it goes on to say (in 4.3) "The presence of a message-body in a
request is signaled by the inclusion of a Content-Length or
Transfer-Encoding header field in the request's message-headers" does
that not imply that if there is are no headers then there can be no
body either?  I think the OP was looking for a body with no headers.
Not to be confused with a headless body which would be quite
different.

Colin
1a4ff0766a653c62e0dab34bacda9873?d=identicon&s=25 Norbert Melzer (Guest)
on 2014-06-24 21:56
(Received via mailing list)
He gets that snippet from another server, the opening does not want to
create a body without headers, he wants to extract the actual body out
of a
full HTTP-response he got from external services.

So easiest way would be to drop everything before the first (and
including
it) newline, the remainder is the body, as described in the HTTP-RFC...
Am 24.06.2014 20:14 schrieb "Colin Law" <clanlaw@gmail.com>:
5b9dffc647cd2ca8a8a1487846ec6ad9?d=identicon&s=25 Tok L. (tok_l)
on 2014-06-24 22:44
Norbert Melzer wrote in post #1150632:
> He gets that snippet from another server, the opening does not want to
> create a body without headers, he wants to extract the actual body out
> of a
> full HTTP-response he got from external services.
>
> So easiest way would be to drop everything before the first (and
> including
> it) newline, the remainder is the body, as described in the HTTP-RFC...
> Am 24.06.2014 20:14 schrieb "Colin Law" <clanlaw@gmail.com>:

Hi Norbert

My client only wish to receive the http body from me (rails application
with nginx) and he is unable to extract from a full http response.
Therefore any advise to just sent down only the response body is still
very much appreciated.

T

Ps I also want to thank all have responded so far.
50d9a1c52e39ca209b5ab3386d0176bc?d=identicon&s=25 Jay Dee (ftumsh)
on 2014-06-25 10:38
Colin,
Yes, it does say that, however, the "or" is important as it also says
that the transfer encoding may be removed.
The OP wants to send a response without any headers. This is within the
rfc and so should be doable, regardless of how retarded it seems to be
:)
50d9a1c52e39ca209b5ab3386d0176bc?d=identicon&s=25 Jay Dee (ftumsh)
on 2014-06-25 10:42
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-25 23:17
(Received via mailing list)
On 25 June 2014 09:38, Jay Dee <lists@ruby-forum.com> wrote:
> Colin,
> Yes, it does say that, however, the "or" is important as it also says
> that the transfer encoding may be removed.

Don't follow you there, where does it say the transfer encoding may be
removed?

Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.