(data []byte)
| 244 | } |
| 245 | |
| 246 | func 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 | } |
no test coverage detected