tumblr / jumblr

Tumblr API v2 Java Client
Apache License 2.0
278 stars 105 forks source link

Avatar requests set no-follow-redirects locally #95

Open ceyko opened 8 years ago

ceyko commented 8 years ago

When making an avatar request, or any request using RequestBuilder#getRedirectUrl(), we need to not follow any redirects, since the response of getRedirectUrl() is the Location of the redirect. Previously, we accomplished this via HttpURLConnection#setFollowRedirects(). However, this sets it globally, for any callers of HttpURLConnection.

We attempted to have our don't-follow-redirects requirement not affect any other callers by setting it back to its original value after making the request. However, this is not thread-safe. This pull request makes it so that we only change whether redirects are followed for this instance of HttpURLConnection by instead using OAuthRequest#setFollowRedirects(), which calls HttpURLConnection#setInstanceFollowRedirects() internally.

The requisite method was only added as of Scribe 1.3.5, so we also needed upgrade the dependency. 1.3.7 is the latest version on the 1.x tree, and there weren't many changes between 1.3.5 and 1.3.7, so we decided to use 1.3.7 instead. I know #83 will obsolete this version upgrade, but just adding it in for now to fix this bug.

cc @ericleong @KevinTCoughlin @bdenney

Fixes #94