Hi guys, I'm having trouble with sending request to URL which precedes redirection to another one after receiving 301
.
request('http://www.tanitbar.ru/menu.aspx?cat=6', function (error, response, body) {
console.log('error:', error);
console.log("response", response);
});,
1) First response contains status code equals to 301 (that means that we should redirect to URL from location
header, but it contains encoded Russian letters: СалаÑÑ
2) Since this URL (http://www.tanitbar.ru/СалаÑÑ
) doesn't exist, I'm getting 404
error
Expect to get html body of page, with status code equals to 200
I'm getting 404
for now
curl
works fine and redirects to another URL after receiving 301
curl "http://www.tanitbar.ru/menu.aspx?cat=6" -L
, (curl doesn't redirect by default, therefore we need to pass -L
option)
I guess we should decode location header somehow before redirection (By the way I could not decode it by hand)
Couldn't receive content of the page from JS.
| software | version
| ---------------- | -------
| request |^2.83.0
| node |8.7.0
| npm |5.4.2
| Operating System | Linux, Ubuntu
Thanks in advance!
Do we even do anything with the encoding of that header? I think we just get it right from Node.js' parser.
@mikeal https://github.com/nodejs/node/issues/17390 may be related
By the way, that Buffer.from(location, 'binary').toString('utf8')
works for me.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@mikeal https://github.com/nodejs/node/issues/17390 may be related
By the way, that
Buffer.from(location, 'binary').toString('utf8')
works for me.