From: mark.j.leonard Date: Wed, 19 Sep 2018 17:57:46 +0000 (+0100) Subject: Specify Content-Type in all HTTP requests X-Git-Tag: 1.3.1~13 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fsearch-data-service.git;a=commitdiff_plain;h=d6f71a1ecc6f7f758f516b226af5b128b2a0d9e1 Specify Content-Type in all HTTP requests Explicitly specify all HTTP payload content as JSON, for compatibility with Elasticsearch 6.x Change-Id: Ibd6ad7bfd627a5c1bdfb04a950472e4cedfd790d Issue-ID: AAI-1650 Signed-off-by: mark.j.leonard --- diff --git a/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java b/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java index 841f477..a93274e 100644 --- a/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java +++ b/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java @@ -342,7 +342,6 @@ public class ElasticSearchHttpController implements DocumentStoreInterface { try { conn.setRequestMethod("PUT"); - conn.setRequestProperty("Content-Type", "application/json"); } catch (ProtocolException e) { shutdownConnection(conn); throw new DocumentStoreOperationException("Failed to set HTTP request method to PUT.", e); @@ -405,7 +404,6 @@ public class ElasticSearchHttpController implements DocumentStoreInterface { try { conn.setRequestMethod("PUT"); - conn.setRequestProperty("Content-Type", "application/json"); } catch (ProtocolException e) { shutdownConnection(conn); throw new DocumentStoreOperationException("Failed to set HTTP request method to PUT.", e); @@ -553,7 +551,6 @@ public class ElasticSearchHttpController implements DocumentStoreInterface { private void attachDocument(HttpURLConnection conn, DocumentStoreDataEntity doc) throws DocumentStoreOperationException { - conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Connection", "Close"); attachContent(conn, doc.getContentInJson()); } @@ -640,7 +637,6 @@ public class ElasticSearchHttpController implements DocumentStoreInterface { try { conn.setRequestMethod("PUT"); - conn.setRequestProperty("Content-Type", "application/json"); } catch (ProtocolException e) { shutdownConnection(conn); throw new DocumentStoreOperationException("Failed to set HTTP request method to PUT.", e); @@ -805,7 +801,6 @@ public class ElasticSearchHttpController implements DocumentStoreInterface { try { conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); } catch (ProtocolException e) { shutdownConnection(conn); throw new DocumentStoreOperationException("Failed to set HTTP request method to POST.", e); @@ -854,7 +849,6 @@ public class ElasticSearchHttpController implements DocumentStoreInterface { try { conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); } catch (ProtocolException e) { shutdownConnection(conn); throw new DocumentStoreOperationException("Failed to set HTTP request method to POST.", e); @@ -913,6 +907,7 @@ public class ElasticSearchHttpController implements DocumentStoreInterface { try { conn = (HttpURLConnection) url.openConnection(); + conn.setRequestProperty("Content-Type", "application/json"); conn.setDoOutput(true); } catch (IOException e) { shutdownConnection(conn);