Skip to content

Commit

Permalink
Setting content-type header on outbound requests
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Oct 12, 2018
1 parent ef73cff commit c5a7614
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions lib/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2018
* @license BSD-3-Clause
* @version 4.3.4
* @version 4.3.5
*/
"use strict";

Expand Down Expand Up @@ -995,20 +995,21 @@
}

try {
result = await this.request(uri, {method: "patch", body: JSON.stringify(body, null, 0)});
result = await this.request(uri, {method: "patch", headers: {"content-type": "application/json-patch+json"}, body: JSON.stringify(body, null, 0)});
} catch (e) {
if (e[1] === 405) {
this.patch = false;
result = await this.request(!data ? concatURI(this.uri, key) : uri, {
method: method,
headers: {"content-type": "application/json"},
body: JSON.stringify(data, null, 0)
});
} else {
throw e;
}
}
} else {
result = await this.request(uri, {method: method, body: JSON.stringify(data, null, 0)});
result = await this.request(uri, {method: method, headers: {"content-type": "application/json"}, body: JSON.stringify(data, null, 0)});
}

return result;
Expand Down Expand Up @@ -1085,7 +1086,7 @@
}

factory.transform = cast;
factory.version = "4.3.4";
factory.version = "4.3.5";

// Node, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
4 changes: 2 additions & 2 deletions lib/haro.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/haro.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haro",
"version": "4.3.4",
"version": "4.3.5",
"description": "Harō is a modern immutable DataStore",
"main": "lib/haro.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,20 +680,21 @@
}

try {
result = await this.request(uri, {method: "patch", body: JSON.stringify(body, null, 0)});
result = await this.request(uri, {method: "patch", headers: {"content-type": "application/json-patch+json"}, body: JSON.stringify(body, null, 0)});
} catch (e) {
if (e[1] === 405) {
this.patch = false;
result = await this.request(!data ? concatURI(this.uri, key) : uri, {
method: method,
headers: {"content-type": "application/json"},
body: JSON.stringify(data, null, 0)
});
} else {
throw e;
}
}
} else {
result = await this.request(uri, {method: method, body: JSON.stringify(data, null, 0)});
result = await this.request(uri, {method: method, headers: {"content-type": "application/json"}, body: JSON.stringify(data, null, 0)});
}

return result;
Expand Down

0 comments on commit c5a7614

Please sign in to comment.