Skip to content

Commit

Permalink
content-length (batch)
Browse files Browse the repository at this point in the history
  • Loading branch information
oklemenz2 committed Jul 4, 2024
1 parent 27907ca commit d12c27d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Version 1.12.12 - 2024-07-04

### Fixed

- Set `content-length` header correctly for OData V4 request in batch mode

### Added

- CI Matrix Test Node 22
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,14 @@ function cov2ap(options = {}) {
}
body = convertRequestBody(body, headers, url, req);
}
if (body !== undefined) {
for (const name in headers) {
if (name.toLowerCase() === "content-length") {
headers[name] = Buffer.byteLength(body);
break;
}
}
}
return { body, headers };
},
req.contentIdOrder,
Expand Down
3 changes: 2 additions & 1 deletion test/_env/util/batch/Batch-POST.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Content-ID: 1

POST Header HTTP/1.1
Content-Type: application/json
Content-Length: 39

{"name":"Test – ABC"}
{"name":"Test – ABC","__metadata":{}}
--boundary
Content-Type: application/http

Expand Down

0 comments on commit d12c27d

Please sign in to comment.