/// <inheritdoc /> public async Task <byte[]> Retrieve( Uri bulkdataUri, Tuple <int, int?> byteRange, params DicomTransferSyntax[] transferSyntaxes) { Guard.Against.Null(bulkdataUri, nameof(bulkdataUri)); if (bulkdataUri.IsAbsoluteUri) { Guard.Against.MalformUri(bulkdataUri, nameof(bulkdataUri)); } transferSyntaxes = transferSyntaxes.Trim(); _logger?.Log(LogLevel.Debug, $"Sending HTTP request to {bulkdataUri}"); var message = new HttpRequestMessage(HttpMethod.Get, bulkdataUri); message.Headers.Add(HeaderNames.Accept, BuildAcceptMediaHeader(MimeType.OctetStreme, transferSyntaxes)); if (byteRange != null) { message.AddRange(byteRange); } var response = await _httpClient.SendAsync(message).ConfigureAwait(false); response.EnsureSuccessStatusCode(); return(await response.ToBinaryData()); }
public void AddRange_ByteRangeHasValidValues() { HttpRequestMessage request = new HttpRequestMessage(); request.AddRange(new Tuple <int, int?>(100, 200)); var range = request.Headers.Range; Assert.Equal("byte", range.Unit); Assert.Equal(100, range.Ranges.First().From); Assert.Equal(200, range.Ranges.First().To); }
public void AddRange_ByteRangeIsNull() { HttpRequestMessage request = new HttpRequestMessage(); request.AddRange(null); var range = request.Headers.Range; Assert.Equal("byte", range.Unit); Assert.Equal(0, range.Ranges.First().From); Assert.Null(range.Ranges.First().To); }
public void AddRange_ByteRangeHasOnlyStart() { HttpRequestMessage request = new HttpRequestMessage(); request.AddRange(new Tuple <int, int?>(100, null)); var range = request.Headers.Range; Assert.Equal("byte", range.Unit); Assert.Equal(100, range.Ranges.First().From); Assert.Null(range.Ranges.First().To); }
public void AddRange_Null() { HttpRequestMessage request = null; Assert.Throws <ArgumentNullException>(() => request.AddRange(null)); }