Re: How to fetch http accept raw string?

33 views
Skip to first unread message

greelgorke

unread,
May 16, 2013, 9:07:14 AM5/16/13
to expre...@googlegroups.com
request.headers['accept']

Am Sonntag, 12. Mai 2013 14:13:22 UTC+2 schrieb Crispin Schäffler:
Hi,

im new to Node.js and Express.js (coming from Ruby on Rails and Ruby w/ Sinatra).

So I need to access the HTTP ACCEPT header in one of my functions.

I know with express if i have something like this:

app.get('/', function(req, res) {
  req.accepted();
});

However, this returns an array with accepted MIME types sorted by Quality.

Is there a way i can access the raw string of the HTTP ACCEPTED header?

I want something returned like this (or without the Accept: infront, but that is optional):

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Brian Falk

unread,
May 15, 2013, 2:39:26 PM5/15/13
to expre...@googlegroups.com
try req.get('Accept') or req.header('Accept')


On Sun, May 12, 2013 at 8:13 AM, Crispin Schäffler <crispins...@gmail.com> wrote:
Hi,

im new to Node.js and Express.js (coming from Ruby on Rails and Ruby w/ Sinatra).

So I need to access the HTTP ACCEPT header in one of my functions.

I know with express if i have something like this:

app.get('/', function(req, res) {
  req.accepted();
});

However, this returns an array with accepted MIME types sorted by Quality.

Is there a way i can access the raw string of the HTTP ACCEPTED header?

I want something returned like this (or without the Accept: infront, but that is optional):

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

--
You received this message because you are subscribed to the Google Groups "Express" group.
To unsubscribe from this group and stop receiving emails from it, send an email to express-js+...@googlegroups.com.
To post to this group, send email to expre...@googlegroups.com.
Visit this group at http://groups.google.com/group/express-js?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages