• Stars
    star
    211
  • Rank 186,867 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

curl to C# converter

curl to C#

Build status Quality Gate Docker pulls

This ASP.NET Core app converts curl commands to C# code

Demo

https://curl.olsh.me

Telegram bot

https://t.me/curl_to_csharp_bot

Run with docker

  1. Run container
docker run -p 8080:80 olsh/curl-to-csharp
  1. Open http://localhost:8080

Run locally

You can grab latest binaries here and run dotnet CurlToCSharp.dll

Build

  1. Install cake
dotnet tool install -g Cake.Tool
  1. Run build
dotnet cake build.cake

NuGet Packages

Curl.CommandLine.Parser

NuGet

Key Features

  • Parses cURL command into individual cURL options.
  • Returns parsing errors and warnings if the cURL input is invalid.

Installation

Install with NuGet

dotnet add package Curl.CommandLine.Parser

Usage/Examples

var input = @"curl https://sentry.io/api/0/projects/1/groups/?status=unresolved -d '{""status"": ""resolved""}' -H 'Content-Type: application/json' -u 'username:password' -H 'Accept: application/json' -H 'User-Agent: curl/7.60.0'";

var output = new CurlParser(new ParsingOptions() { MaxUploadFiles = 10 }).Parse(input);

Console.WriteLine(output.Data.UploadData.First().Content);
// Output:
// {"status": "resolved"}

Curl.HttpClient.Converter

NuGet

Key Features

  • Converts output from CurlParser into C# code.
  • Returns parsing errors and warnings if the cURL input is invalid.

Installation

Install with NuGet

dotnet add package Curl.HttpClient.Converter

Usage/Examples

var input = @"curl https://sentry.io/api/0/projects/1/groups/?status=unresolved -d '{""status"": ""resolved""}' -H 'Content-Type: application/json' -u 'username:password' -H 'Accept: application/json' -H 'User-Agent: curl/7.60.0'";
var curlOption = new CurlParser().Parse(input);
var output = new CurlHttpClientConverter().ToCsharp(curlOption.Data);
// Output:
/*
// In production code, don't destroy the HttpClient through using, but better reuse an existing instance
// https://www.aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/
using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://sentry.io/api/0/projects/1/groups/?status=unresolved"))
    {
        request.Headers.TryAddWithoutValidation("Accept", "application/json");
        request.Headers.TryAddWithoutValidation("User-Agent", "curl/7.60.0");

        var base64authorization = Convert.ToBase64String(Encoding.ASCII.GetBytes("username:password"));
        request.Headers.TryAddWithoutValidation("Authorization", $"Basic {base64authorization}");

        request.Content = new StringContent("{\"status\": \"resolved\"}");
        request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

        var response = await httpClient.SendAsync(request);
    }
}
*/

More Repositories

1

Feedly-Notifier

Google Chrome, Firefox, Opera and Microsoft Edge extension for reading news from RSS aggregator Feedly
JavaScript
266
star
2

resharper-structured-logging

An extension for ReSharper and Rider that highlights structured logging templates and contains some useful analyzers
C#
123
star
3

todoist-net

A Todoist API client for .NET written in C#
C#
67
star
4

datagrip-poco-generator

An extension for IntelliJ-based IDEs (DataGrip, Rider, etc.) to generate POCO (C#) classes from a database
Groovy
58
star
5

resharper-configuration-sense

An extension for ReSharper and Rider IDE that provides autocomplete and validation for App settings and Connections strings
C#
40
star
6

resharper-bootstrap-templates

Bootstrap Live Templates for quick markup generation
C#
28
star
7

Feedly-Notifier-Firefox

[DEPRECATED - https://github.com/olsh/Feedly-Notifier] Firefox extension for reading news from rss aggregator Feedly
JavaScript
22
star
8

dotnet-consolidate

.NET core command-line tool that verifies that all NuGet packages in a solution are consolidated
C#
19
star
9

dotnet-reqube

.NET Core global tool that converts ReSharper inspect code report to SonarQube format
C#
9
star
10

stack-exchange-redis-analyzer

Roslyn-based analyzer for StackExchange.Redis library
C#
9
star
11

teamcity-jira-release-notes

The TeamCity meta-runner generates release notes for the current build using TeamCity and Jira API
PowerShell
7
star
12

sql-analyzer-net

Roslyn-based analyzer for SQL related stuff in .NET
C#
6
star
13

Google-Tasks-Sidebar

Firefox addon that shows your Google tasks in a sidebar.
JavaScript
6
star
14

monkey-testing

A simple Google Chrome extension for monkey testing based on gremlins.js
JavaScript
4
star
15

XNotifier-Habrahabr

Script for browser plugin X-Notifier that checks tracker and conversations on habrahabr.ru website
JavaScript
4
star
16

Feedly-Notifier-Safari

Safari extension for reading news from rss aggregator Feedly
JavaScript
4
star
17

olsh.github.io

https://olsh.me
HTML
3
star
18

sentry-api-client

A Sentry API client for .NET
C#
2
star
19

Feedly-Notifier-Opera

[DEPRECATED - https://github.com/olsh/Feedly-Notifier] Opera extension for reading news from rss aggregator Feedly
JavaScript
2
star
20

resharper-to-sonarqube-example

This repository contains an example project which shows how you can send ReSharper code issues to SonarQube
HTML
1
star
21

mvc5-custom-error-pages-example

JavaScript
1
star