From d6f71a1ecc6f7f758f516b226af5b128b2a0d9e1 Mon Sep 17 00:00:00 2001 From: "mark.j.leonard" Date: Wed, 19 Sep 2018 18:57:46 +0100 Subject: [PATCH] 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 --- .../elasticsearch/dao/ElasticSearchHttpController.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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); -- 2.16.6