MCPcopy
hub / github.com/nodejs/undici / clone

Method clone

lib/web/fetch/request.js:780–813  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

778
779 // Returns a clone of request.
780 clone () {
781 webidl.brandCheck(this, Request)
782
783 // 1. If this is unusable, then throw a TypeError.
784 if (bodyUnusable(this.#state)) {
785 throw new TypeError('unusable')
786 }
787
788 // 2. Let clonedRequest be the result of cloning this’s request.
789 const clonedRequest = cloneRequest(this.#state)
790
791 // 3. Let clonedRequestObject be the result of creating a Request object,
792 // given clonedRequest, this’s headers’s guard, and this’s relevant Realm.
793 // 4. Make clonedRequestObject’s signal follow this’s signal.
794 const ac = new AbortController()
795 if (this.signal.aborted) {
796 ac.abort(this.signal.reason)
797 } else {
798 let list = dependentControllerMap.get(this.signal)
799 if (list === undefined) {
800 list = new Set()
801 dependentControllerMap.set(this.signal, list)
802 }
803 const acRef = new WeakRef(ac)
804 list.add(acRef)
805 util.addAbortListener(
806 ac.signal,
807 buildAbort(acRef)
808 )
809 }
810
811 // 4. Return clonedRequestObject.
812 return fromInnerRequest(clonedRequest, this.#dispatcher, ac.signal, getHeadersGuard(this.#headers))
813 }
814
815 [nodeUtil.inspect.custom] (depth, options) {
816 if (options.depth === null) {

Callers

nothing calls this directly

Calls 9

bodyUnusableFunction · 0.85
cloneRequestFunction · 0.85
buildAbortFunction · 0.85
fromInnerRequestFunction · 0.85
brandCheckMethod · 0.80
abortMethod · 0.65
getMethod · 0.65
addMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected