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

followRedirect: true is not working #948

Open
vigilancer opened this issue Dec 23, 2021 · 3 comments
Open

followRedirect: true is not working #948

vigilancer opened this issue Dec 23, 2021 · 3 comments

Comments

@vigilancer
Copy link

Option "followRedirect: true" is not working.

How to reproduce

add something like this to file with .http extension and run request with this plugin from VS Code.

POST /auth/login HTTP/1.1
Host: api.XXX

{"username":"test@test.te","password":"test"}

api.XXX should be changed with appropriate example. I'm working with private API and cannot share details but any endpoint that answers with 301 will do.

Solution

I've spend some time debugging and seems to be the problem is in the got library.
Apparently got@9.6.0 does not respect followRedirect flag that plugin is passing to it.
Last version got@12.0.0 on the other hand do respect followRedirect.

Here are some code that you could try and see it for yourself:

got@9.6.0:

const url = 'http://api.XXX/auth/login'
const response = await got.post(url, {
	body: {
		username: 'XXX',
               password: 'XXX'
	},
    json: true,
    followRedirect: true,
})
console.log(response.statusCode, "\n", response.rawHeaders);

got@12.0.0:

const url = 'http://api.XXX/auth/login'
const response = await got.post(url, {
	json: {
        username: 'XXX',
        password: 'XXX'
	},
   followRedirect: true,
});
console.log(response.statusCode, "\n", response.rawHeaders);

Are you planing to update the got library?
They've changed API since then but nothing critical AFAIK and this seems quite doable.

  • REST Client Version: 0.24.6
  • VSCode Version: 1.63.2
@AnWeber
Copy link

AnWeber commented Dec 24, 2021

got 12 switched to esm. See sindresorhus/got#1789. Rest client is commonjs. Switching to esm is doable, but needs some time. Maybe try got 11 which also supports followRedirect correctly. Tested with my own extension.

@vigilancer
Copy link
Author

Nice catch, thank you.

I'm ready to invest some time. @Huachao will you consider PR with got upgrade from 9.6 to 11?

@Huachao
Copy link
Owner

Huachao commented Dec 28, 2021

@vigilancer of course, just ensure it is well tested :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants