GithubHelp home page GithubHelp logo

amingolmahalle / httpclienttocurlgenerator Goto Github PK

View Code? Open in Web Editor NEW
46.0 3.0 9.0 220 KB

The HttpClientToCurl is a NuGet package for generating curl script of HttpClient in .NET ( C# | CSharp | Dotnet ) supported features: Post, Get, Put, and Delete. content types: application/json, text/xml, application/x-www-form-urlencoded

Home Page: https://www.nuget.org/packages/HttpClientToCurl

License: MIT License

C# 98.29% Shell 1.71%
asp-net-core aspnetcore csharp curl extension httpclient dotnet postman dotnet-standard json

httpclienttocurlgenerator's Introduction

💫 About Me:

🔭 I’m currently working in Asan Pardakht
👯 I’m currently working with C#, Python

🌐 Socials:

LinkedIn Stack Overflow

💻 Tech Stack:

C# Python .Net Flask Nginx MicrosoftSQLServer Redis Postgres MongoDB MySQL LINUX Docker Swagger Postman ElasticSearch Jira Trello Confluence

📊 GitHub Stats:




httpclienttocurlgenerator's People

Contributors

amingolmahalle avatar naeemaei avatar sabermotamedi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

httpclienttocurlgenerator's Issues

Proposal: Add Sample Projects for Better Documentation

Issue Description

Objective:

Improve project documentation by adding sample projects that demonstrate how to use the library.

Details:

As a user, I find it beneficial to have concrete examples of how to use the library in different scenarios. Adding sample projects will make it easier for users to understand and implement the library's features.

Proposed Solution:

Create a new directory named examples in the project root and include sample projects showcasing various use cases. Each sample project should have its own README file explaining its purpose and how to run it.

Suggested Sample Projects:

  1. Basic Usage: A simple project demonstrating the basic features of the library.
  2. Advanced Usage: An advanced project showcasing more complex usage scenarios.
  3. Integration with Other Libraries: A project demonstrating how to integrate this library with other popular libraries.

Additional Notes:

  • Ensure that each sample project is well-documented.
  • Encourage community contributions for additional sample projects.
  • Consider providing a script or instructions to easily clone and run all sample projects.

Include all header values

When appending header values, use string.Join("; ", header.Value) instead to include all header values.

Show more details in case of errors

I tried to find my error by your extension but I only received this message:
"GenerateCurlError => Object reference not set to an instance of an object..".

Definitely, this message is not enough for me to find my fault it's better to be aware of which object is null or has a problem.

I will fix it.

Refactor Unit Tests to use xUnit Framework

This change is part of the effort to transition from NUnit to xUnit for our testing framework. Please make sure to update any necessary dependencies and follow the xUnit conventions for test structure and assertions.

Why BaseUrl of HttpClient is mandatory?

In some scenarios, I want to set an absolute path in HttpRequestMessage but had forced me to use HttpClient BaseUrl.
It would be great if there was a way I could just set the absolute path in the HttpRequestMessage.

Add cURL compressed command-line option

Add the cURL --compressed command-line option to the outputted command-line by default. Most requests nowadays have compression encoding, i.e. the header Accept-Encoding: gzip; deflate; br.

Use readme.md file in nuget readme

It's better to use the readme file content in nuget description.
To achieve this we should create a HttpClientToCurlGenerator.nuspec file in the project like this:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <!-- Required elements-->
        <id>HttpClientToCurlGenerator</id>
        <version>2.0.3</version>
        <description>An extension for generating Curl script of HttpClient</description>
        <authors>Amin</authors>
        <summary>
          This extension will help you to see whatever is set in HttpClient in the form of a curl script.
        </summary>
        <releaseNotes>
          ...
        </releaseNotes>

        <projectUrl>https://github.com/amingolmahalle/HttpClientToCurlGenerator</projectUrl>
        <repository type="git" url="https://github.com/amingolmahalle/HttpClientToCurlGenerator.git" branch="main" />

        <license type="expression">MIT</license>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <tags>csharp HTTP httpclient curl</tags>
        <icon>icon.png</icon>
        <readme>README.md</readme>
    </metadata>
    <!-- Optional 'files' node -->

    <files> 
        <file src="README.md" /> 
    </files>
</package>

Exclude `Content-Length` from curl

The output curl shouldn't include the Content-Length header, this header computes automatically.

Example:

curl -X POST 'http://localhost:8090/v1/api/test' -H 'Authorization: Bearer f69406a4-6b62-4734-a8dc-158f0fc308ab' -H 'Content-Type: application/json; charset=utf-8' -H 'Content-Length: 214' -d '{"name":"test","requestId":7000,"amount":9000000}' 

add pre-commit and pre-push files to curl generator

Description:

We need to add pre-commit and pre-push hooks to enhance awareness of our code quality.

Steps to Reproduce:

To achieve this, we should add a configuration file to the project.

Expected Behavior:

Contributors will be more confident about their code quality as it will be automatically checked before commits and pushes.

Additional Information:

An additional file is suggested to be added to the project to implement these hooks.

Please review and consider implementing this enhancement.

pre-commit.zip

Quote the URL

On the outputted cURL command-line, add quotes around the URL to prevent characters like ? and & being handled by a shell.

Example: Instead of curl https://foo.com?bar=baz&red=sox, change it to be curl 'https://foo.com?bar=baz&red=sox'

Without quoting, every command-line with characters like these must be edited prior to execution.

Query params not escaped in url, resulting in invalid curl command.

Hi,

Thanks for the plugin, it was a great for debugging.

Minor problem, query params are not escaped.

Example:

var queryArgs = new Dictionary<string, StringValues>
{  
     { "memberId", "Morten Sjøgren" },
};

var uri = new Uri(QueryHelpers.AddQueryString("http://internal-backend.lan/rest/path", queryArgs));

I'd expect this to become:

curl http://internal-system.lan/rest/path\?memberName=Morten%20Sj%C3%B8gren

But I get this:

curl http://internal-system.lan/rest/path\?memberName=Morten Sjøgren

Which of course doesn't work because of the space and the unescaped danish letter ø.

📝 Integrate EditorConfig for Code Consistency

Add EditorConfig to Project

Hello @amingolmahalle ,

I've been considering the benefits of introducing an EditorConfig to our project, and I believe it could significantly enhance our codebase. Here are a few key points:

Reasons for Adding EditorConfig:

  • Ensures consistent coding styles across the project.
  • Facilitates easier collaboration by standardizing indentation settings.
  • Improves code readability and maintainability.

Benefits:

  • Streamlines the development process by reducing style-related conflicts.
  • Enhances the overall quality of our codebase.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.