You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let needle = require('needle');
let url = "http://www.business-standard.com/article/opinion/sunil-sethi-ye-gods-what-have-we-done-to-deserve-this…-116092301178_1.html";
let options = {
compressed:true,
follow_max: 20,
user_agent:'Mozilla/5.0 (Windows NT 6.2; rv:22.0) Gecko/20130405 Firefox/23.0',
open_timeout: 20*1000,
rejectUnauthorized: true,
follow_set_cookies: true,
follow_set_referer: true
}
needle.get(url, options, (err, res) => {
if(res)
console.log(res.headers['content-type']);
if (err){
console.error(err);
}else{
console.log(res.body);
}
});
Falls with an error:
_http_outgoing.js:370
throw new TypeError('The header content contains invalid characters');
^
TypeError: The header content contains invalid characters
at ClientRequest.setHeader (_http_outgoing.js:370:11)
at new ClientRequest (_http_client.js:131:14)
at Object.request (http.js:26:10)
at Needle.send_request (/home/ubuntu/workspace/node_modules/needle/lib/needle.js:425:26)
at ClientRequest.<anonymous> (/home/ubuntu/workspace/node_modules/needle/lib/needle.js:467:21)
at Object.onceWrapper (events.js:291:19)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:189:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:522:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
If remove option - follow_set_referer: true, it is works.
How I can fix it?
The text was updated successfully, but these errors were encountered:
Code:
Falls with an error:
If remove option -
follow_set_referer: true
, it is works.How I can fix it?
The text was updated successfully, but these errors were encountered: