MCPcopy
hub / github.com/request/request / end

Function end

request.js:528–566  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

526 }
527
528 var end = function () {
529 if (self._form) {
530 if (!self._auth.hasAuth) {
531 self._form.pipe(self)
532 } else if (self._auth.hasAuth && self._auth.sentAuth) {
533 self._form.pipe(self)
534 }
535 }
536 if (self._multipart && self._multipart.chunked) {
537 self._multipart.body.pipe(self)
538 }
539 if (self.body) {
540 if (isstream(self.body)) {
541 self.body.pipe(self)
542 } else {
543 setContentLength()
544 if (Array.isArray(self.body)) {
545 self.body.forEach(function (part) {
546 self.write(part)
547 })
548 } else {
549 self.write(self.body)
550 }
551 self.end()
552 }
553 } else if (self.requestBodyStream) {
554 console.warn('options.requestBodyStream is deprecated, please pass the request object to stream.pipe.')
555 self.requestBodyStream.pipe(self)
556 } else if (!self.src) {
557 if (self._auth.hasAuth && !self._auth.sentAuth) {
558 self.end()
559 return
560 }
561 if (self.method !== 'GET' && typeof self.method !== 'undefined') {
562 self.setHeader('content-length', 0)
563 }
564 self.end()
565 }
566 }
567
568 if (self._form && !self.hasHeader('content-length')) {
569 // Before ending the request, we had to compute the length of the whole form, asyncly

Callers 1

request.jsFile · 0.85

Calls 1

setContentLengthFunction · 0.85

Tested by

no test coverage detected