Skip to content

Commit 6ff61de

Browse files
committed
Remove utf8-length dependency
1 parent f341c53 commit 6ff61de

File tree

5 files changed

+3
-13
lines changed

5 files changed

+3
-13
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"es6-error": "^4.0.1",
6363
"linkedlist": "^1.0.1",
6464
"multi-part": "^2.0.0",
65-
"utf8-length": "^0.0.1",
6665
"xhr": "^2.4.1"
6766
},
6867
"devDependencies": {

src/connection.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { stringify as querystringify } from "querystring";
22
import { ArangoError, HttpError } from "./error";
3-
import { byteLength } from "./util/bytelength";
43
import {
54
ArangojsResponse,
65
createRequest,
@@ -304,13 +303,6 @@ export class Connection {
304303
"x-arango-version": String(this._arangoVersion)
305304
};
306305

307-
if (!isBrowser) {
308-
// Node doesn't set content-length but ArangoDB needs it
309-
extraHeaders["content-length"] = String(
310-
body ? byteLength(body, "utf-8") : 0
311-
);
312-
}
313-
314306
this._queue.push({
315307
retries: 0,
316308
host,

src/util/bytelength.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/util/bytelength.web.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/util/request.node.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export function createRequest(
6060
: url.search
6161
: baseUrlParts.search;
6262
if (search) path += search;
63+
if (typeof body === "string" && !headers["content-length"]) {
64+
headers["content-length"] = String(Buffer.byteLength(body));
65+
}
6366
const options: any = { path, method, headers, agent };
6467
options.hostname = baseUrlParts.hostname;
6568
options.port = baseUrlParts.port;

0 commit comments

Comments
 (0)