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

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