Follow the redirection if a HTTP 301, 302, or 307 is returned #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.