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

Follow the redirection if a HTTP 301, 302, or 307 is returned #86

Merged
merged 2 commits into from
Jun 22, 2015

Conversation

branliu0
Copy link
Contributor

This is a small fix to make the API follow any HTTP 3xx redirects that MediaWiki may return. I bumped into this recently after Wikipedia turned on HTTPS-always, and I had been previously using the HTTP endpoint. Right now, if you hit a redirect, then you get an extremely cryptic error message MediaWiki::Exception: Bad response:

The gist of the fix is: RestClient normally will follow redirects for you, but if you pass a block to RestClient::Request.execute, then it does not follow redirects. So here is the simplest fix for following redirects.

I manually tested this: Before my change, using the HTTP endpoint would result in an error. After the change, I can successfully make queries, even when initializing the Gateway to the HTTP endpoint.

jpatokal added a commit that referenced this pull request Jun 22, 2015
Follow the redirection if a HTTP 301, 302, or 307 is returned
@jpatokal jpatokal merged commit 27ef552 into jpatokal:master Jun 22, 2015
@jpatokal
Copy link
Owner

Brilliant, thank you!

@branliu0 branliu0 deleted the redirect branch August 9, 2015 23:13
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

Successfully merging this pull request may close these issues.

2 participants