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

Method write

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

Source from the content-addressed store, hash-verified

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

Callers 15

processAsyncCmdFunction · 0.45
appendToLogFileFunction · 0.45
_completeMethod · 0.45
printNextLocalFrameMethod · 0.45
printNextCIFrameMethod · 0.45
hideCursorMethod · 0.45
showCursorMethod · 0.45
runGracefulMethod · 0.45
handlerFunction · 0.45
handlerFunction · 0.45
handlerFunction · 0.45
server.mjsFile · 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