How to get the string of the original HTTP header in node.js using express.js

I am currently working with node.js and express.js. For my current project, I need to access the raw HTTP header lines (charset and accpeted).

Express.js has a function that returns these encodings and accepted headers, however they are sorted by quality and therefore are not suitable for me in this special case, which I need.

req.accepted // Returns sorted array of accepted header req.acceptedCharsets // Returns sorted array of accepted lang header 

However, I need raw strings (iso-8859-5; q = .2, unicode-1-1; q = 0.8, text / *; q = .5, application / json).

Now there is a way, how can I access these raw strings in my express application?

Regards, Crispin

+4
source share
1 answer

req.headers

how in

  var express = require('express'); var app = express.createServer(); app.get('/', function(req, res){ console.log(req.headers); res.header('time', 12345); res.send('Hello World'); }); app.listen(3000); 
+8
source

Source: https://habr.com/ru/post/1480432/


All Articles