diff --git a/src/main/java/org/codelibs/fess/app/web/admin/backup/AdminBackupAction.java b/src/main/java/org/codelibs/fess/app/web/admin/backup/AdminBackupAction.java index 08211e870..9654ab87b 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/backup/AdminBackupAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/backup/AdminBackupAction.java @@ -81,14 +81,16 @@ public class AdminBackupAction extends FessAdminAction { logger.warn("Failed to process system.properties file: " + form.bulkFile.getFileName(), e); } } else { - try (CurlResponse response = Curl.post(ResourceUtil.getElasticsearchHttpUrl() + "/_bulk").onConnect((req, con) -> { - con.setDoOutput(true); - try (InputStream in = form.bulkFile.getInputStream(); OutputStream out = con.getOutputStream()) { - CopyUtil.copy(in, out); - } catch (IOException e) { - throw new IORuntimeException(e); - } - }).execute()) { + try (CurlResponse response = + Curl.post(ResourceUtil.getElasticsearchHttpUrl() + "/_bulk").header("Content-Type", "application/json") + .onConnect((req, con) -> { + con.setDoOutput(true); + try (InputStream in = form.bulkFile.getInputStream(); OutputStream out = con.getOutputStream()) { + CopyUtil.copy(in, out); + } catch (IOException e) { + throw new IORuntimeException(e); + } + }).execute()) { if (logger.isDebugEnabled()) { logger.debug("Bulk Response:\n" + response.getContentAsString()); } @@ -127,8 +129,8 @@ public class AdminBackupAction extends FessAdminAction { return asStream(filename).contentTypeOctetStream().stream( out -> { try (CurlResponse response = - Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/" + index + "/_data").param("format", "json") - .execute()) { + Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/" + index + "/_data") + .header("Content-Type", "application/json").param("format", "json").execute()) { out.write(response.getContentAsStream()); } }); diff --git a/src/main/java/org/codelibs/fess/app/web/admin/esreq/AdminEsreqAction.java b/src/main/java/org/codelibs/fess/app/web/admin/esreq/AdminEsreqAction.java index ded1401f1..89d72784b 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/esreq/AdminEsreqAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/esreq/AdminEsreqAction.java @@ -82,7 +82,7 @@ public class AdminEsreqAction extends FessAdminAction { return asListHtml(() -> saveToken()); }); } else { - try (final CurlResponse response = curlRequest.body(buf.toString()).execute()) { + try (final CurlResponse response = curlRequest.header("Content-Type", "application/json").body(buf.toString()).execute()) { final File tempFile = File.createTempFile("esreq_", ".json"); try (final InputStream in = response.getContentAsStream()) { CopyUtil.copy(in, tempFile); diff --git a/src/main/java/org/codelibs/fess/dict/DictionaryManager.java b/src/main/java/org/codelibs/fess/dict/DictionaryManager.java index 87a841c23..b09b9c6ea 100644 --- a/src/main/java/org/codelibs/fess/dict/DictionaryManager.java +++ b/src/main/java/org/codelibs/fess/dict/DictionaryManager.java @@ -50,8 +50,9 @@ public class DictionaryManager { public DictionaryFile[] getDictionaryFiles() { try (CurlResponse response = - Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("fields", "path,@timestamp") - .param("size", ComponentUtil.getFessConfig().getPageDictionaryMaxFetchSize()).execute()) { + Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").header("Content-Type", "application/json") + .param("fields", "path,@timestamp").param("size", ComponentUtil.getFessConfig().getPageDictionaryMaxFetchSize()) + .execute()) { final Map contentMap = response.getContentAsMap(); @SuppressWarnings("unchecked") final List> fileList = (List>) contentMap.get("file"); @@ -96,8 +97,8 @@ public class DictionaryManager { // TODO use stream try (CurlResponse response = - Curl.post(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()) - .body(FileUtil.readUTF8(file)).execute()) { + Curl.post(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").header("Content-Type", "application/json") + .param("path", dictFile.getPath()).body(FileUtil.readUTF8(file)).execute()) { final Map contentMap = response.getContentAsMap(); if (!Constants.TRUE.equalsIgnoreCase(contentMap.get("acknowledged").toString())) { throw new DictionaryException("Failed to update " + dictFile.getPath()); @@ -113,8 +114,8 @@ public class DictionaryManager { public InputStream getContentInputStream(final DictionaryFile dictFile) { try { - return Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()).execute() - .getContentAsStream(); + return Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").header("Content-Type", "application/json") + .param("path", dictFile.getPath()).execute().getContentAsStream(); } catch (final IOException e) { throw new DictionaryException("Failed to access " + dictFile.getPath(), e); }