
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
A C# .NET 6 library for parallel async request handling. Features include priority settings, retry functions, and expandable classes, making it ideal for HTTP requests and CPU-intensive tasks.
Requests is library for C# .NET 6; it's your trusty sidekick in the world of handling requests. Imagine a friendly companion that takes care of your requests, ensuring they're processed efficiently and systematically. Whether you're dealing with HTTP requests or tackling CPU-intensive tasks like directory searching.
Getting started with Requests is a breeze:
To utilize the Requests library in C#, begin by importing it:
using Shard.Requests;
Next, instantiate a Request
object, and it will automatically be included in the RequestHandler
. If a request encounters an error, the RequestHandler
will automatically retry the request based on the specified retry settings.
This library includes the following classes:
Request
started, failed, completed, or canceled 📢CancellationToken
and a main CancellationTokenSource
to cancel the request.Progress
object to report the progress.Expand and use as you like!
Because handling requests should be as delightful as a warm cup of cocoa on a winter day.
For additional information, refer to the Requests Wiki.
Meet our star, the OwnRequest
class:
public class OwnRequest : Request<RequestOptions<VoidStruct, VoidStruct>, VoidStruct, VoidStruct>
{
private readonly Func<CancellationToken, Task<bool>> _own;
public OwnRequest(Func<CancellationToken, Task<bool>> own, RequestOptions<VoidStruct, VoidStruct>? requestOptions = null) : base(requestOptions)
{
_own = own;
AutoStart();
}
protected override async Task<RequestReturn> RunRequestAsync()
{
return new RequestReturn() { Successful = await _own.Invoke(Token) };
}
}
OwnRequest is a straightforward implementation of a child class of Request. It doesn’t overwhelm you with complexity, but it’s incredibly useful for quick implementations:
// Create an object and pass as a parameter an action that uses a CancellationToken
new OwnRequest(async (token) =>
{
using HttpClient client = new();
// 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
HttpResponseMessage response = await client.SendAsync(requestMessage, token);
// If the response does not succeed
if (!response.IsSuccessStatusCode)
return false; // Return false to retry and call the failed method
// If the response succeeds. Do what you want and return to finish the request
Console.WriteLine("Finished");
return true;
});
Create your own requests with a sprinkle of magic! ✨
Join our quest! If you'd like to contribute to this library, submit a pull request or open an issue. We appreciate your help in making Requests
the best it can be!
Requests is licensed under the MIT license.
FAQs
A C# .NET 6 library for parallel async request handling. Features include priority settings, retry functions, and expandable classes, making it ideal for HTTP requests and CPU-intensive tasks.
We found that shard.requests demonstrated a healthy version release cadence and project activity because the last version was released less than 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
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.