moved s3-specific handler into s3 module

This commit is contained in:
Adrian Cole 2012-01-10 12:15:14 -08:00
parent 467381bd51
commit c675b61807
2 changed files with 6 additions and 7 deletions

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.aws.handlers;
package org.jclouds.s3.handlers;
import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
@ -40,11 +40,11 @@ import org.jclouds.http.handlers.RedirectionRetryHandler;
* @author Adrian Cole
*/
@Singleton
public class AWSRedirectionRetryHandler extends RedirectionRetryHandler {
public class S3RedirectionRetryHandler extends RedirectionRetryHandler {
private final AWSUtils utils;
@Inject
public AWSRedirectionRetryHandler(Provider<UriBuilder> uriBuilderProvider,
public S3RedirectionRetryHandler(Provider<UriBuilder> uriBuilderProvider,
BackoffLimitedRetryHandler backoffHandler, AWSUtils utils) {
super(uriBuilderProvider, backoffHandler);
this.utils = utils;
@ -54,7 +54,8 @@ public class AWSRedirectionRetryHandler extends RedirectionRetryHandler {
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null
&& (response.getStatusCode() == 301 || response.getStatusCode() == 307)) {
if (command.getCurrentRequest().getMethod() == HttpMethod.HEAD) {
if (command.getCurrentRequest().getMethod().equals(HttpMethod.HEAD)) {
command.incrementRedirectCount();
command.setCurrentRequest(command.getCurrentRequest().toBuilder().method("GET").build());
return true;
} else {

View File

@ -24,11 +24,9 @@ import java.net.URI;
import java.util.Map;
import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import javax.inject.Singleton;
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler;
@ -36,6 +34,7 @@ import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Provider;
import org.jclouds.location.Region;
import org.jclouds.location.config.ProvideRegionToURIViaProperties;
@ -73,7 +72,6 @@ public class AWSRestClientModule<S, A> extends RestClientModule<S, A> {
@Override
protected void bindRetryHandlers() {
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(AWSRedirectionRetryHandler.class);
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AWSClientErrorRetryHandler.class);
}