Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js request.js HPE_INVALID_HEADER_TOKEN

Tags:

http

node.js

I got desperate about one problem and I need some help... I'm using node.js to crawl a list of websites, some of them gives me this error, for example: http://www.fz-juelich.de/portal/DE/Home/home_node.html, Parse Error, HPE_INVALID_HEADER_TOKEN

request.get({
    url: uri,
    timeout: timeout,
    headers: {
        referer: domain
    }
}, (error, response, body) => {
    if (error)
        console.log(error);
    console.log(body);
});

though, curl -i --raw http://www.fz-juelich.de/portal/DE/Home/home_node.html works just perfect

HTTP/1.1 404 Not Found
Server: Apache-Coyote/1.1
Cache-Control: no-cache
JSESSIONID=E594677A6CCA13BE0338E1D00A729C34; Path=/cae:
Content-Type: text/html;charset=utf-8
Content-Language: de
Set-Cookie: JSESSIONID=E594677A6CCA13BE0338E1D00A729C34; Path=/
Content-Length: 19677

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

Also I'm able to see this website in my chrome browser

Any ideas in which side should I dig to get rid of this errors?

like image 637
let4be Avatar asked Jul 09 '26 14:07

let4be


1 Answers

I use quotes in properties and that resolve for me :

request.post(url,{
    headers: {
      'Authorization': 'Basic onEnAGrosEncodedBase64',
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    form: {
      'grant_type': 'client_credentials'
    }
 })

I hope that can help someone ;)

like image 182
Yehr59 Avatar answered Jul 12 '26 11:07

Yehr59



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!