Imperugo.HttpRequestToCurl
1.0.14
dotnet add package Imperugo.HttpRequestToCurl --version 1.0.14
NuGet\Install-Package Imperugo.HttpRequestToCurl -Version 1.0.14
<PackageReference Include="Imperugo.HttpRequestToCurl" Version="1.0.14" />
paket add Imperugo.HttpRequestToCurl --version 1.0.14
#r "nuget: Imperugo.HttpRequestToCurl, 1.0.14"
// Install Imperugo.HttpRequestToCurl as a Cake Addin #addin nuget:?package=Imperugo.HttpRequestToCurl&version=1.0.14 // Install Imperugo.HttpRequestToCurl as a Cake Tool #tool nuget:?package=Imperugo.HttpRequestToCurl&version=1.0.14
Imperugo.HttpRequestToCurl
The idea of this library is to have a curl from an HttpRequest instance. The library produce a string that could be logged everywhere (console, db and so on).
Read the blog post here for more information.
Quickstart
Installation
Add the NuGet Package to your project:
dotnet add package Imperugo.HttpRequestToCurl
Usage
The useage is absolutely easy. Just add the reference and, anywhere in your code write this:
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Imperugo.HttpRequestToCurl.Sample.Models;
namespace Imperugo.HttpRequestToCurl.Sample.Controllers;
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public async Task<IActionResult> IndexAsync()
{
var curl = await Request.ToCurlAsync();
_logger.LogDebug(curl);
return View();
}
}
That code produces this output
dbug: Imperugo.HttpRequestToCurl.Sample.Controllers.HomeController[0]
curl --location --request GET 'http://localhost:5069/'
--header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8'
--header 'Connection: keep-alive'
--header 'Host: localhost:5069'
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
--header 'Accept-Encoding: gzip, deflate, br'
--header 'Accept-Language: en-GB,en'
--header 'Cache-Control: max-age=0'
--header 'Upgrade-Insecure-Requests: 1'
--header 'sec-ch-ua: "Brave";v="107", "Chromium";v="107", "Not=A?Brand";v="24"'
--header 'sec-ch-ua-mobile: ?0'
--header 'sec-ch-ua-platform: "macOS"'
--header 'Sec-GPC: 1'
--header 'Sec-Fetch-Site: none'
--header 'Sec-Fetch-Mode: navigate'
--header 'Sec-Fetch-User: ?1'
--header 'Sec-Fetch-Dest: document'
If you want to use the
--insecure
you could do it with the specific parameter.var curl = await Request.ToCurlAsync(insecure:true);
By default the ToCurl
command generates an output that is compatible with the Bash but, if you are running on Windows or another system and you need a different output, you can specify it as parameter
Right now the supported output are:
- Bash (default)
- Command
- Powershell
var curl = await Request.ToCurlAsync(Extensions.ToCurlOptions.CmdExe);
Sample
Take a look here
License
Imperugo.HttpRequestToCurl MIT licensed.
Contributing
Thanks to all the people who already contributed!
<a href="https://github.com/imperugo/HttpRequestToCurl/graphs/contributors"> <img src="https://contributors-img.web.app/image?repo=imperugo/HttpRequestToCurl" /> </a>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Imperugo.HttpRequestToCurl:
Package | Downloads |
---|---|
Imperugo.HttpRequestLogger
An extension method that create the cURL starting from an HttpRequest |
|
Imperugo.HttpRequestLogger.Abstractions
An extension method that create the cURL starting from an HttpRequest |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.14 | 3,105 | 6/24/2024 |
1.0.13 | 1,077 | 4/30/2024 |
1.0.12 | 4,487 | 1/17/2023 |
1.0.11 | 300 | 1/17/2023 |
1.0.9 | 436 | 12/19/2022 |
1.0.8 | 867 | 12/5/2022 |
1.0.7 | 311 | 12/5/2022 |
1.0.6 | 329 | 12/5/2022 |
1.0.5 | 320 | 12/4/2022 |
1.0.4 | 318 | 12/4/2022 |
1.0.3 | 326 | 12/4/2022 |
1.0.2 | 332 | 12/4/2022 |
1.0.1 | 332 | 12/4/2022 |