From f8ed285e5f9cc4241dc3fa908212ed65f5f41078 Mon Sep 17 00:00:00 2001 From: caixiangyue Date: Tue, 6 Jul 2021 15:48:14 +0800 Subject: [PATCH] add Content-Type header --- daemon/http-tx-mgr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/daemon/http-tx-mgr.c b/daemon/http-tx-mgr.c index 19c87f39a..ee1c6ed77 100644 --- a/daemon/http-tx-mgr.c +++ b/daemon/http-tx-mgr.c @@ -856,6 +856,9 @@ http_put (CURL *curl, const char *url, const char *token, /* Disable the default "Expect: 100-continue" header */ headers = curl_slist_append (headers, "Expect:"); + if (req_content) + headers = curl_slist_append (headers, "Content-Type: application/octet-stream"); + if (token) { token_header = g_strdup_printf ("Seafile-Repo-Token: %s", token); headers = curl_slist_append (headers, token_header); @@ -978,6 +981,16 @@ http_post (CURL *curl, const char *url, const char *token, /* Disable the default "Expect: 100-continue" header */ headers = curl_slist_append (headers, "Expect:"); + if (req_content) { + json_t *is_json = NULL; + is_json = json_loads (req_content, 0, NULL); + if (is_json) { + headers = curl_slist_append (headers, "Content-Type: application/json"); + json_decref (is_json); + } else + headers = curl_slist_append (headers, "Content-Type: application/octet-stream"); + } + if (token) { token_header = g_strdup_printf ("Seafile-Repo-Token: %s", token); headers = curl_slist_append (headers, token_header);