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

Method write

github-actions/browserstack/set-browserstack-env.js:6945–6994  ·  view source on GitHub ↗
(chunk)

Source from the content-addressed store, hash-verified

6943 writer.destroy(err);
6944 } finally {
6945 socket.off("close", onDrain).off("drain", onDrain);
6946 }
6947 });
6948 }
6949 var AsyncWriter = class {
6950 constructor({ abort, socket, request, contentLength, client, expectsPayload, header }) {
6951 this.socket = socket;
6952 this.request = request;
6953 this.contentLength = contentLength;
6954 this.client = client;
6955 this.bytesWritten = 0;
6956 this.expectsPayload = expectsPayload;
6957 this.header = header;
6958 this.abort = abort;
6959 socket[kWriting] = true;
6960 }
6961 write(chunk) {
6962 const { socket, request, contentLength, client, bytesWritten, expectsPayload, header } = this;
6963 if (socket[kError]) {
6964 throw socket[kError];
6965 }
6966 if (socket.destroyed) {
6967 return false;
6968 }
6969 const len = Buffer.byteLength(chunk);
6970 if (!len) {
6971 return true;
6972 }
6973 if (contentLength !== null && bytesWritten + len > contentLength) {
6974 if (client[kStrictContentLength]) {
6975 throw new RequestContentLengthMismatchError();
6976 }
6977 process.emitWarning(new RequestContentLengthMismatchError());
6978 }
6979 socket.cork();
6980 if (bytesWritten === 0) {
6981 if (!expectsPayload && request.reset !== false) {
6982 socket[kReset] = true;
6983 }
6984 if (contentLength === null) {
6985 socket.write(`${header}transfer-encoding: chunked\r
6986`, "latin1");
6987 } else {
6988 socket.write(`${header}content-length: ${contentLength}\r
6989\r
6990`, "latin1");
6991 }
6992 }
6993 if (contentLength === null) {
6994 socket.write(`\r
6995${len.toString(16)}\r
6996`, "latin1");
6997 }

Callers 15

_transformMethod · 0.45
onDataFunction · 0.45
writeBufferFunction · 0.45
writeBlobFunction · 0.45
writeIterableFunction · 0.45
endMethod · 0.45
_resumeFunction · 0.45
onDataMethod · 0.45
packageDataFunction · 0.45
closeWebSocketConnectionFunction · 0.45
onSocketDataFunction · 0.45
decompressMethod · 0.45

Calls 6

__awaiterFunction · 0.70
toStringMethod · 0.45
onBodySentMethod · 0.45
refreshMethod · 0.45
filePathMethod · 0.45
emptyBufferMethod · 0.45

Tested by

no test coverage detected