MCPcopy Create free account
hub / github.com/angular/dev-infra / writeBuffer

Function writeBuffer

github-actions/browserstack/set-browserstack-env.js:6827–6857  ·  view source on GitHub ↗
(abort, body, client, request, socket, contentLength, header, expectsPayload)

Source from the content-addressed store, hash-verified

6825 }
6826 }
6827 function writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload) {
6828 try {
6829 if (!body) {
6830 if (contentLength === 0) {
6831 socket.write(`${header}content-length: 0\r
6832\r
6833`, "latin1");
6834 } else {
6835 assert(contentLength === null, "no body must not have content length");
6836 socket.write(`${header}\r
6837`, "latin1");
6838 }
6839 } else if (util.isBuffer(body)) {
6840 assert(contentLength === body.byteLength, "buffer body must have content length");
6841 socket.cork();
6842 socket.write(`${header}content-length: ${contentLength}\r
6843\r
6844`, "latin1");
6845 socket.write(body);
6846 socket.uncork();
6847 request.onBodySent(body);
6848 if (!expectsPayload && request.reset !== false) {
6849 socket[kReset] = true;
6850 }
6851 }
6852 request.onRequestSent();
6853 client[kResume]();
6854 } catch (err) {
6855 abort(err);
6856 }
6857 }
6858 function writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload) {
6859 return __async(this, null, function* () {
6860 assert(contentLength === body.size, "blob body must have content length");

Callers 2

writeH1Function · 0.70
writeBodyH2Function · 0.70

Calls 5

abortFunction · 0.70
writeMethod · 0.45
onBodySentMethod · 0.45
onRequestSentMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected