Skip to content

Commit

Permalink
add Content-Type header
Browse files Browse the repository at this point in the history
  • Loading branch information
caixiangyue committed Jul 6, 2021
1 parent 0fdc14d commit f8ed285
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions daemon/http-tx-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f8ed285

Please sign in to comment.