
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Shard.DonwloadLibrary
Advanced tools
A free to use library as wrapper around the HttpClient to use as a download manager or as easy producer consumer implementation. All Requests will be handled by an PriorityQueue in a parallel state to have a simple and efficient way to handle many Requests. Tested with more than 1000 HttpRequests. Also includes retry, priority and cancel function. Classes: • StatusRequest: Calls a Head request and returns a response message with the headers. • OwnRequest: Wrapper around your own requests. Easy to self-expand function. • SiteRequest: Scans a website for all references. • LoadRequest: To download the response into a file. o This is a HTTP file downloader with pause and resuming function. Returns an IProgress to get the download progress.
The Shard Download Library is an on .Net 6.0 based wrapper around the HttpClient
to manage your HTTP requests. But it can also be used without the HttpClient
to handle CPU intensive tasks.
All Requests
will be handled by an PriorityChannel
in a Parallel asyncron state to have a simple and efficient way to handle many (simultaneously tested with more than 1000) HTTP Requests.
At the moment:
Request
started, failed, completed, or canceledCancellationToken
and a main CancellationTokenSource
on Downloader
to cancel all downloadsIProgress<float>
Expand and use as you like!
It is available on Github:
Installation over NuGet Package manager in Visual Studio or online. Package Manager Console: PM> NuGet\Install-Package Shard.DonwloadLibrary
Import the Library.
using DownloaderLibrary.Web.Request;
Then create a new Request
object like this LoadRequest
.
This LoadRequest
downloads a file into the download's folder of the PC with a ".part" file and uses the name that the server provides.
//To download a file and store it in "Downloads" folder
new LoadRequest("[Your URL]"); // e.g. https://www.sample-videos.com/video123/mkv/240/big_buck_bunny_240p_30mb.mkv
To set options on the Request
create a RequestOption
or for a LoadRequest
a LoadRequestOption
.
// Create an option for a LoadRequest
LoadRequestOptions requestOptions = new()
{
// Sets the filename of the download without the extension
// The extension will be added automatically!
FileName = "downloadfile",
// If this download has priority (default is false)
Priority = RequestPriority.High,
//(default is download folder)
DestinationPath = "C:\\Users\\[Your Username]\\Desktop",
// If this Request contains a heavy request put it in second thread (default is false)
IsDownload = true,
//If the downloader should Override, Create a new file or Append (default is Append)
//Resume function only available with append!
Mode = LoadMode.Create,
// Progress that writes the % to the Console
Progress = new Progress<float>(f => Console.WriteLine((f).ToString("0.0%"))),
//Chunk a file to download faster
Chunks = 3
};
And use it in the request.
//To download a file and store it on the Desktop with a different name
new LoadRequest(" https://speed.hetzner.de/100MB.bin",requestOptions);
To wait on the request, use await or Wait();.
await new LoadRequest(" https://speed.hetzner.de/100MB.bin",requestOptions).Task;
//new LoadRequest(" https://speed.hetzner.de/100MB.bin",requestOptions).Wait();
Create an OwnRequest
like this:
//Create an object that passes a CancellationToken
new OwnRequest((downloadToken) =>
{
//Create your request Message. Here the body of google.com
HttpRequestMessage requestMessage = new(HttpMethod.Get, "https://www.google.com");
//Send your request and get the result. Pass the CancellationToken for handling it later over the Request object
var response = await RequestObject.HttpClient.SendAsync(requestMessage, downloadToken);
//If the response does not succeed
if (!response.IsSuccessStatusCode)
return false; // Return false to retry and call the failed method
//If the response succeed. Do what you want and return to to finish the request
Console.WriteLine("Finished");
return true;
});
To create your own Request
child. Here is the implementation of the OwnRequest
class:
public class OwnRequest : : Request<RequestOptions<VoidStruct, VoidStruct>, VoidStruct, VoidStruct>
{
private readonly Func<CancellationToken, Task<bool>> _own;
//Parent doesn't require a RequestOption because it creates then a new one.
//But to use the options it have to be passed over to the parent
public OwnRequest(Func<CancellationToken, Task<bool>> own, RequestOptions<VoidStruct, VoidStruct>? requestOptions = null) : base(requestOptions)
{
_own = own;
//Has to be called to inject it into the management process
AutoStart();
}
// Here will the Request be handled and a object returned that indicates if it succeed
protected override async Task<RequestReturn> RunRequestAsync() => new()
{
Successful = await _own.Invoke(Token)
};
}
MIT
FAQs
A free to use library as wrapper around the HttpClient to use as a download manager or as easy producer consumer implementation. All Requests will be handled by an PriorityQueue in a parallel state to have a simple and efficient way to handle many Requests. Tested with more than 1000 HttpRequests. Also includes retry, priority and cancel function. Classes: • StatusRequest: Calls a Head request and returns a response message with the headers. • OwnRequest: Wrapper around your own requests. Easy to self-expand function. • SiteRequest: Scans a website for all references. • LoadRequest: To download the response into a file. o This is a HTTP file downloader with pause and resuming function. Returns an IProgress to get the download progress.
We found that shard.donwloadlibrary demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.