* ============LICENSE_END=========================================================\r
*/\r
\r
-/*\r
- * ============LICENSE_START==========================================\r
- * ===================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END============================================\r
- *\r
- * ECOMP and OpenECOMP are trademarks\r
- * and service marks of AT&T Intellectual Property.\r
- *\r
- */\r
\r
package com.woorea.openstack.connector;\r
\r
* The {@link org.apache.http.client.DefaultRedirectStrategy} only\r
* redirects GET and HEAD automatically, per the HTTP specification\r
* (POST and PUT typically have bodies and thus cannot be redirected).\r
- * \r
+ *\r
* A custom strategy is needed for the Openstack API, which can also send\r
* 302 on a DELETE (by name) request, expecting the client to follow the\r
- * redirect to perform the actual deletion. \r
+ * redirect to perform the actual deletion.\r
*/\r
@Immutable\r
public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {\r
* Redirectable methods.\r
*/\r
private static final String[] REDIRECT_METHODS = new String[] {\r
- HttpGet.METHOD_NAME,\r
- HttpDelete.METHOD_NAME,\r
- HttpHead.METHOD_NAME\r
+ HttpGet.METHOD_NAME,\r
+ HttpDelete.METHOD_NAME,\r
+ HttpHead.METHOD_NAME\r
};\r
\r
/**\r
final HttpRequest request,\r
final HttpResponse response,\r
final HttpContext context) throws ProtocolException {\r
- \r
+\r
final URI uri = getLocationURI(request, response, context);\r
final String method = request.getRequestLine().getMethod();\r
if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {\r
} else {\r
\r
final int status = response.getStatusLine().getStatusCode();\r
- \r
+\r
HttpUriRequest newRequest;\r
if (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == HttpStatus.SC_MOVED_TEMPORARILY) {\r
newRequest = RequestBuilder.copy(request).setUri(uri).build();\r
return newRequest;\r
}\r
}\r
-}\r
+}
\ No newline at end of file
* ============LICENSE_END=========================================================
*/
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property. 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License 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.
- * ============LICENSE_END============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
package com.woorea.openstack.connector;
public class HttpClientResponse implements OpenStackResponse {
private static Logger LOGGER = LoggerFactory.getLogger(HttpClientConnector.class);
-
+
private HttpResponse response = null;
private String entityBody = null;
public HttpClientResponse(HttpResponse response)
{
this.response = response;
-
+
// Read the body so InputStream can be closed
if (response.getEntity() == null) {
// No body
LOGGER.debug ("No Response Body");
return;
}
-
+
ByteArrayOutputStream responseBody = new ByteArrayOutputStream();
try {
response.getEntity().writeTo(responseBody);
LOGGER.debug (entityBody);
}
-
+
@Override
public <T> T getEntity (Class<T> returnType) {
// Get appropriate mapper, based on existence of a root element
@Override
public InputStream getInputStream() {
- return new ByteArrayInputStream (entityBody.getBytes());
+ return new ByteArrayInputStream (entityBody.getBytes());
}
@Override
return headers;
}
-}
+}
\ No newline at end of file