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 body.on("data", onData).on("end", onFinished).on("error", onFinished).on("close", onClose);
6828 if (body.resume) {
6829 body.resume();
6830 }
6831 socket.on("drain", onDrain).on("error", onFinished);
6832 if ((_a = body.errorEmitted) != null ? _a : body.errored) {
6833 setImmediate(() => onFinished(body.errored));
6834 } else if ((_b = body.endEmitted) != null ? _b : body.readableEnded) {
6835 setImmediate(() => onFinished(null));
6836 }
6837 if ((_c = body.closeEmitted) != null ? _c : body.closed) {
6838 setImmediate(onClose);
6839 }
6840 }
6841 function writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload) {
6842 try {
6843 if (!body) {
6844 if (contentLength === 0) {
6845 socket.write(`${header}content-length: 0\r
6846\r
6847`, "latin1");
6848 } else {
6849 assert(contentLength === null, "no body must not have content length");
6850 socket.write(`${header}\r
6851`, "latin1");
6852 }
6853 } else if (util.isBuffer(body)) {
6854 assert(contentLength === body.byteLength, "buffer body must have content length");
6855 socket.cork();
6856 socket.write(`${header}content-length: ${contentLength}\r
6857\r
6858`, "latin1");
6859 socket.write(body);
6860 socket.uncork();

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