gist_plugin: Handle multiple redirects, stopping if we find a circular r...

...eference

This is another fix for gist_plugin.rb that handles any number of redirects and stops if it's ever redirected back to a location it's already been to.

Fixes #1503 and #1505