Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2016. Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.http.apache.client.impl;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
import java.io.IOException;
/**
* An instance of {@link ConnectionManagerAwareHttpClient} that delegates all the requests to the given http client.
*/
public class SdkHttpClient implements
ConnectionManagerAwareHttpClient {
private final HttpClient delegate;
private final HttpClientConnectionManager cm;
public SdkHttpClient(final HttpClient delegate,
final HttpClientConnectionManager cm) {
if (delegate == null) {
throw new IllegalArgumentException("delegate " +
"cannot be null");
}
if (cm == null) {
throw new IllegalArgumentException("connection manager " +
"cannot be null");
}
this.delegate = delegate;
this.cm = cm;
}
@Override
public HttpParams getParams() {
return delegate.getParams();
}
@Override
public ClientConnectionManager getConnectionManager() {
return delegate.getConnectionManager();
}
@Override
public HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException {
return delegate.execute(request);
}
@Override
public HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException {
return delegate.execute(request, context);
}
@Override
public HttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolException {
return delegate.execute(target, request);
}
@Override
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException {
return delegate.execute(target, request, context);
}
@Override
public T execute(HttpUriRequest request, ResponseHandler responseHandler) throws IOException, ClientProtocolException {
return delegate.execute(request, responseHandler);
}
@Override
public T execute(HttpUriRequest request, ResponseHandler responseHandler, HttpContext context) throws IOException, ClientProtocolException {
return delegate.execute(request, responseHandler, context);
}
@Override
public T execute(HttpHost target, HttpRequest request, ResponseHandler responseHandler) throws IOException, ClientProtocolException {
return delegate.execute(target, request, responseHandler);
}
@Override
public T execute(HttpHost target, HttpRequest request, ResponseHandler responseHandler, HttpContext context) throws IOException, ClientProtocolException {
return delegate.execute(target, request, responseHandler, context);
}
@Override
public HttpClientConnectionManager getHttpClientConnectionManager() {
return cm;
}
}