Imperugo.HttpRequestToCurl 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Imperugo.HttpRequestToCurl --version 1.0.6                
NuGet\Install-Package Imperugo.HttpRequestToCurl -Version 1.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Imperugo.HttpRequestToCurl" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Imperugo.HttpRequestToCurl --version 1.0.6                
#r "nuget: Imperugo.HttpRequestToCurl, 1.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Imperugo.HttpRequestToCurl as a Cake Addin
#addin nuget:?package=Imperugo.HttpRequestToCurl&version=1.0.6

// Install Imperugo.HttpRequestToCurl as a Cake Tool
#tool nuget:?package=Imperugo.HttpRequestToCurl&version=1.0.6                

Imperugo.HttpRequestToCurl

Nuget Nuget GitHub

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).

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);

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 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.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,054 6/24/2024
1.0.13 1,076 4/30/2024
1.0.12 4,486 1/17/2023
1.0.11 299 1/17/2023
1.0.9 435 12/19/2022
1.0.8 866 12/5/2022
1.0.7 310 12/5/2022
1.0.6 328 12/5/2022
1.0.5 319 12/4/2022
1.0.4 317 12/4/2022
1.0.3 325 12/4/2022
1.0.2 331 12/4/2022
1.0.1 331 12/4/2022