Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request is not redirected due to encoded location header #2835

Closed
matrosov-nikita opened this issue Jan 2, 2018 · 3 comments
Closed

Request is not redirected due to encoded location header #2835

matrosov-nikita opened this issue Jan 2, 2018 · 3 comments
Labels

Comments

@matrosov-nikita
Copy link

matrosov-nikita commented Jan 2, 2018

Summary

Hi guys, I'm having trouble with sending request to URL which precedes redirection to another one after receiving 301.

Simplest Example to Reproduce

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

Expected Behavior

Expect to get html body of page, with status code equals to 200

Current Behavior

I'm getting 404 for now

Possible Solution

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)

Context

Couldn't receive content of the page from JS.

Your Environment

software version
request ^2.83.0
node 8.7.0
npm 5.4.2
Operating System Linux, Ubuntu

Thanks in advance!

@mikeal
Copy link
Member

mikeal commented Jan 2, 2018

Do we even do anything with the encoding of that header? I think we just get it right from Node.js' parser.

@matrosov-nikita
Copy link
Author

matrosov-nikita commented Jan 2, 2018

@mikeal nodejs/node#17390 may be related
By the way, that Buffer.from(location, 'binary').toString('utf8') works for me.

@stale
Copy link

stale bot commented Jan 2, 2019

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.

@stale stale bot added the stale label Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants