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

Tesla.Middleware.FollowRedirects causes Tesla.Middleware.Query to add query string multiple times #334

Closed
praveenperera opened this issue Nov 13, 2019 · 2 comments
Assignees
Labels

Comments

@praveenperera
Copy link

If you had both

plug Tesla.Middleware.Query [token: "secret"]
plug Tesla.Middleware.FollowRedirects

The ?token="secret" will be added multiple times, each time its redirect.

@praveenperera praveenperera changed the title Tesla.Middleware.FollowRedirects causes Tesla.Middleware.Query to double Tesla.Middleware.FollowRedirects causes Tesla.Middleware.Query to add query string multiple times Nov 13, 2019
@teamon teamon self-assigned this Nov 19, 2019
@teamon
Copy link
Member

teamon commented Nov 19, 2019

Looks like you're right:

defmodule GH334 do
  use Tesla

  plug Tesla.Middleware.Query, token: "secret"
  plug Tesla.Middleware.FollowRedirects
end

{:ok, env} = GH334.get("http://localhost:8888/redirect/4")
200 = env.status
docker run -p 8888:80  -e GUNICORN_CMD_ARGS="--capture-output --error-logfile - --access-logfile - --access-logformat '%(h)s %(t)s %(r)s %(s)s Host: %({Host}i)s}'" kennethreitz/httpbin

172.17.0.1 [19/Nov/2019:10:13:48 +0000] GET /redirect/4?token=secret HTTP/1.1 302 Host: localhost:8888}
172.17.0.1 [19/Nov/2019:10:13:48 +0000] GET /relative-redirect/3?token=secret HTTP/1.1 302 Host: localhost:8888}
172.17.0.1 [19/Nov/2019:10:13:48 +0000] GET /relative-redirect/2?token=secret HTTP/1.1 302 Host: localhost:8888}
172.17.0.1 [19/Nov/2019:10:13:48 +0000] GET /relative-redirect/1?token=secret HTTP/1.1 302 Host: localhost:8888}
172.17.0.1 [19/Nov/2019:10:13:48 +0000] GET /get?token=secret HTTP/1.1 200 Host: localhost:8888}

@teamon teamon closed this as completed in 3195e25 Nov 19, 2019
@teamon
Copy link
Member

teamon commented Nov 19, 2019

Nice catch @praveenperera! Fixed in 3195e25

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