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.
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.