MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / connect

Method connect

src/managers/GitRemoteHTTP.js:185–218  ·  view source on GitHub ↗

* Connects to a remote Git repository and sends a request. * * @param {Object} args * @param {HttpClient} args.http - The HTTP client to use for requests. * @param {ProgressCallback} [args.onProgress] - Callback for progress updates. * @param {string} [args.corsProxy] - Optional CORS

({
    http,
    onProgress,
    corsProxy,
    service,
    url,
    auth,
    body,
    headers,
  })

Source from the content-addressed store, hash-verified

183 * @throws {HttpError} - If the HTTP request fails.
184 */
185 static async connect({
186 http,
187 onProgress,
188 corsProxy,
189 service,
190 url,
191 auth,
192 body,
193 headers,
194 }) {
195 // We already have the "correct" auth value at this point, but
196 // we need to strip out the username/password from the URL yet again.
197 const urlAuth = extractAuthFromUrl(url)
198 if (urlAuth) url = urlAuth.url
199
200 if (corsProxy) url = corsProxify(corsProxy, url)
201
202 headers['content-type'] = `application/x-${service}-request`
203 headers.accept = `application/x-${service}-result`
204 updateHeaders(headers, auth)
205
206 const res = await http.request({
207 onProgress,
208 method: 'POST',
209 url: `${url}/${service}`,
210 body,
211 headers,
212 })
213 if (res.statusCode !== 200) {
214 const { response } = stringifyBody(res)
215 throw new HttpError(res.statusCode, res.statusMessage, response)
216 }
217 return res
218 }
219}

Callers 3

_fetchFunction · 0.80
_pushFunction · 0.80
listServerRefsFunction · 0.80

Calls 4

extractAuthFromUrlFunction · 0.90
corsProxifyFunction · 0.85
updateHeadersFunction · 0.85
stringifyBodyFunction · 0.85

Tested by

no test coverage detected