|
22 | 22 | import org.apache.commons.logging.Log;
|
23 | 23 | import org.apache.commons.logging.LogFactory;
|
24 | 24 | import org.apache.http.Consts;
|
25 |
| -import org.apache.http.HttpEntity; |
26 |
| -import org.apache.http.HttpResponse; |
27 | 25 | import org.apache.http.NameValuePair;
|
28 |
| -import org.apache.http.StatusLine; |
29 | 26 | import org.apache.http.client.ClientProtocolException;
|
30 |
| -import org.apache.http.client.HttpResponseException; |
31 |
| -import org.apache.http.client.ResponseHandler; |
32 | 27 | import org.apache.http.client.entity.UrlEncodedFormEntity;
|
33 | 28 | import org.apache.http.client.methods.CloseableHttpResponse;
|
34 | 29 | import org.apache.http.client.methods.HttpPost;
|
@@ -140,50 +135,50 @@ private String dumpRequest(HttpServletRequest req) {
|
140 | 135 | return "Request: " + req.getRequestURL() + ", parameters=" + prettyMap;
|
141 | 136 | }
|
142 | 137 |
|
143 |
| - private static class AccessTokenResponseHandler implements |
144 |
| - ResponseHandler<AccessToken> { |
145 |
| - private int statusCode; |
146 |
| - private String reasonPhrase = ""; |
147 |
| - private String content = ""; |
148 |
| - |
149 |
| - @Override |
150 |
| - public AccessToken handleResponse(HttpResponse response) |
151 |
| - throws ClientProtocolException, IOException { |
152 |
| - StatusLine statusLine = response.getStatusLine(); |
153 |
| - this.statusCode = statusLine.getStatusCode(); |
154 |
| - this.reasonPhrase = statusLine.getReasonPhrase(); |
155 |
| - |
156 |
| - if (statusCode >= 300) { |
157 |
| - throw new HttpResponseException(statusLine.getStatusCode(), |
158 |
| - statusLine.getReasonPhrase()); |
159 |
| - } |
160 |
| - HttpEntity entity = response.getEntity(); |
161 |
| - if (entity == null) { |
162 |
| - throw new ClientProtocolException( |
163 |
| - "Response contains no content"); |
164 |
| - } |
165 |
| - this.content = EntityUtils.toString(entity); |
166 |
| - try { |
167 |
| - return new AccessToken(this.content); |
168 |
| - } catch (AccessTokenFormatException e) { |
169 |
| - throw new ClientProtocolException( |
170 |
| - "Failed to parse the access token", e); |
171 |
| - } |
172 |
| - } |
173 |
| - |
174 |
| - public int getStatusCode() { |
175 |
| - return statusCode; |
176 |
| - } |
177 |
| - |
178 |
| - public String getReasonPhrase() { |
179 |
| - return reasonPhrase; |
180 |
| - } |
181 |
| - |
182 |
| - public String getContent() { |
183 |
| - return content; |
184 |
| - } |
185 |
| - |
186 |
| - } |
| 138 | +// private static class AccessTokenResponseHandler implements |
| 139 | +// ResponseHandler<AccessToken> { |
| 140 | +// private int statusCode; |
| 141 | +// private String reasonPhrase = ""; |
| 142 | +// private String content = ""; |
| 143 | +// |
| 144 | +// @Override |
| 145 | +// public AccessToken handleResponse(HttpResponse response) |
| 146 | +// throws ClientProtocolException, IOException { |
| 147 | +// StatusLine statusLine = response.getStatusLine(); |
| 148 | +// this.statusCode = statusLine.getStatusCode(); |
| 149 | +// this.reasonPhrase = statusLine.getReasonPhrase(); |
| 150 | +// |
| 151 | +// if (statusCode >= 300) { |
| 152 | +// throw new HttpResponseException(statusLine.getStatusCode(), |
| 153 | +// statusLine.getReasonPhrase()); |
| 154 | +// } |
| 155 | +// HttpEntity entity = response.getEntity(); |
| 156 | +// if (entity == null) { |
| 157 | +// throw new ClientProtocolException( |
| 158 | +// "Response contains no content"); |
| 159 | +// } |
| 160 | +// this.content = EntityUtils.toString(entity); |
| 161 | +// try { |
| 162 | +// return new AccessToken(this.content); |
| 163 | +// } catch (AccessTokenFormatException e) { |
| 164 | +// throw new ClientProtocolException( |
| 165 | +// "Failed to parse the access token", e); |
| 166 | +// } |
| 167 | +// } |
| 168 | +// |
| 169 | +// public int getStatusCode() { |
| 170 | +// return statusCode; |
| 171 | +// } |
| 172 | +// |
| 173 | +// public String getReasonPhrase() { |
| 174 | +// return reasonPhrase; |
| 175 | +// } |
| 176 | +// |
| 177 | +// public String getContent() { |
| 178 | +// return content; |
| 179 | +// } |
| 180 | +// |
| 181 | +// } |
187 | 182 |
|
188 | 183 | private static class PostRequestBuilder {
|
189 | 184 | private final HttpPost post;
|
|
0 commit comments