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

Avatar requests set no-follow-redirects locally #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ceyko
Copy link
Contributor

@ceyko ceyko commented May 4, 2016

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

ceyko added 2 commits May 3, 2016 14:42
Use the final 1.x release of Scribe. Scribe 1.3.5 adds a new method
OAuthRequest#setFollowRedirects(), which is needed to be able to
(easily) set no-follow on a single request, instead of globally. There
were no concerning changes between 1.3.5 and 1.3.7, so we might as well
bump to the most recent non-breaking version.
When setting no-follow-redirects for RequestBuilder#getRedirectUrl()
(e.g., avatar requests), do so only for this one request. Previously, it
was set globally for all requests, then set back to its initial state
after the request completed. This should prevent multithreading issues
where numerous threads are attempting to alter the global state of
HttpURLConnection#setFollowRedirects().

Fixes #94
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.

jumblrClient.blogAvatar() gets wrong response code?
1 participant