MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / newDownloadRangeClient

Function newDownloadRangeClient

internal/net/request_test.go:246–266  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

244}
245
246func newDownloadRangeClient(data []byte) (*downloadCaptureClient, *int, *[]string) {
247 capture := &downloadCaptureClient{}
248
249 capture.mockedHttpRequest = func(params *HttpRequestParams) (*http.Response, error) {
250 start, fin := params.Range.Start, params.Range.Start+params.Range.Length
251 if params.Range.Length == -1 || fin >= int64(len(data)) {
252 fin = int64(len(data))
253 }
254 bodyBytes := data[start:fin]
255
256 header := &http.Header{}
257 header.Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", start, fin-1, len(data)))
258 return &http.Response{
259 Body: io.NopCloser(bytes.NewReader(bodyBytes)),
260 Header: *header,
261 ContentLength: int64(len(bodyBytes)),
262 }, nil
263 }
264
265 return capture, &capture.GetObjectInvocations, &capture.RetrievedRanges
266}

Callers 4

TestDownloadOrderFunction · 0.85
TestDownloadInterruptFunction · 0.85
TestHighConcurrencyFunction · 0.85
TestDownloadSingleFunction · 0.85

Calls 1

SetMethod · 0.45

Tested by

no test coverage detected