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

FollowRedirects should disregard content headers #265

Open
stevelacey opened this issue Jan 12, 2021 · 1 comment
Open

FollowRedirects should disregard content headers #265

stevelacey opened this issue Jan 12, 2021 · 1 comment

Comments

@stevelacey
Copy link

stevelacey commented Jan 12, 2021

FollowRedirects was failing with a ReadTimeout for me, the reason turned out to be because the request I was doing was a multipart post which naturally has a form multipart Content-Type and a long Content-Length for the post body.

When this request is convert to a GET as per standards_compliance: false these headers should probably be disregarded by default, the POST body is not coming along for the ride so these are definitely going to be wrong.

To achieve this myself I had to use the callback option:

f.use FaradayMiddleware::FollowRedirects, callback: lambda { |response, redirect|
  redirect.request_headers.delete("Content-Length")
  redirect.request_headers.delete("Content-Type")
}
@iMacTia
Copy link
Member

iMacTia commented Jan 12, 2021

Thanks @stevelacey, that makes sense and it would make the middleware smarter.
I won't be able to work on this right now, but hopefully there will be takers ❤️ .

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

No branches or pull requests

2 participants