-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from neon-nyan/pre-v0.0.1.0
Pre v0.0.1.0 Improvements and Changes
- Loading branch information
Showing
19 changed files
with
933 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Threading.Tasks; | ||
|
||
namespace BenchmarkLab | ||
{ | ||
public class DownloadTool | ||
{ | ||
long bufflength = 262144; | ||
HttpClient httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip }); | ||
Stream localStream; | ||
Stream remoteStream; | ||
|
||
public async Task<bool> Dunlud(string inp, string outp) | ||
{ | ||
long ExistingLength = 0; | ||
int byteSize; | ||
localStream = new FileStream(outp, FileMode.Create, FileAccess.Write); | ||
|
||
var request = new HttpRequestMessage { RequestUri = new Uri(inp) }; | ||
request.Headers.Range = new RangeHeaderValue(ExistingLength, null); | ||
|
||
byte[] buffer = new byte[bufflength]; | ||
|
||
using (var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead)) | ||
{ | ||
Console.WriteLine($"{response.Content.Headers.ContentLength ?? 0}"); | ||
using (remoteStream = await response.Content.ReadAsStreamAsync()) | ||
{ | ||
while ((byteSize = await remoteStream.ReadAsync(buffer, 0, buffer.Length)) > 0) | ||
{ | ||
await localStream.WriteAsync(buffer, 0, byteSize); | ||
} | ||
} | ||
} | ||
|
||
localStream.Dispose(); | ||
remoteStream.Dispose(); | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.