1
15 package com.amazonaws.http.apache.client.impl;
16
17 import org.apache.http.HttpHost;
18 import org.apache.http.HttpRequest;
19 import org.apache.http.HttpResponse;
20 import org.apache.http.client.ClientProtocolException;
21 import org.apache.http.client.HttpClient;
22 import org.apache.http.client.ResponseHandler;
23 import org.apache.http.client.methods.HttpUriRequest;
24 import org.apache.http.conn.ClientConnectionManager;
25 import org.apache.http.conn.HttpClientConnectionManager;
26 import org.apache.http.params.HttpParams;
27 import org.apache.http.protocol.HttpContext;
28
29 import java.io.IOException;
30
31
34 public class SdkHttpClient implements
35 ConnectionManagerAwareHttpClient {
36
37 private final HttpClient delegate;
38
39 private final HttpClientConnectionManager cm;
40
41 public SdkHttpClient(final HttpClient delegate,
42 final HttpClientConnectionManager cm) {
43 if (delegate == null) {
44 throw new IllegalArgumentException("delegate " +
45 "cannot be null");
46 }
47 if (cm == null) {
48 throw new IllegalArgumentException("connection manager " +
49 "cannot be null");
50 }
51 this.delegate = delegate;
52 this.cm = cm;
53 }
54
55 @Override
56 public HttpParams getParams() {
57 return delegate.getParams();
58 }
59
60 @Override
61 public ClientConnectionManager getConnectionManager() {
62 return delegate.getConnectionManager();
63 }
64
65 @Override
66 public HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException {
67 return delegate.execute(request);
68 }
69
70 @Override
71 public HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException {
72 return delegate.execute(request, context);
73 }
74
75 @Override
76 public HttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolException {
77 return delegate.execute(target, request);
78 }
79
80 @Override
81 public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException {
82 return delegate.execute(target, request, context);
83 }
84
85 @Override
86 public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException {
87 return delegate.execute(request, responseHandler);
88 }
89
90 @Override
91 public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException, ClientProtocolException {
92 return delegate.execute(request, responseHandler, context);
93 }
94
95 @Override
96 public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException {
97 return delegate.execute(target, request, responseHandler);
98 }
99
100 @Override
101 public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException, ClientProtocolException {
102 return delegate.execute(target, request, responseHandler, context);
103 }
104
105 @Override
106 public HttpClientConnectionManager getHttpClientConnectionManager() {
107 return cm;
108 }
109 }
110