Convert curl command to a ParsedRequest

Related tags

Parsing curl-parser
Overview

CURL Parser

Nowadays, most of the APIs provide CURL examples to allow users to try out the APIs without any entry barriers, but it takes time to digest the examples and convert them into Rust code. This crate could convert CURL commands into Rust code.

At the moment, it supports -X, -H, -d and -u options since these are the most widely used ones.

Usage

"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/email/visibility "#; let parsed = curl_parser::ParsedRequest::try_from(input)?; println!("{:#?}", parsed); let req: reqwest::RequestBuilder = parsed.into(); let res = req.send().await?; assert_eq!(res.status(), 200);">
let input = r#"curl \
    -X PATCH \
    -d '{"visibility":"private"}' \
    -H "Accept: application/vnd.github+json" \
    -H "Authorization: Bearer "\
    -H "X-GitHub-Api-Version: 2022-11-28" \
    https://api.github.com/user/email/visibility "#;
let parsed = curl_parser::ParsedRequest::try_from(input)?;
println!("{:#?}", parsed);
let req: reqwest::RequestBuilder = parsed.into();
let res = req.send().await?;
assert_eq!(res.status(), 200);

By default, reqwest is enabled so that you can convert ParsedRequest into a reqwest::RequestBuilder. If you don't want to use reqwest, you can disable the default features.

You might also like...
Command-line tool to convert Apple HealthKit data to a SQLite database.

healthkit-to-sqlite Command-line tool to convert Apple HealthKit data to a SQLite database. Getting Started Open the Health app on your iOS device. Cl

Program to check if stereo wav files have identical channels (faux-stereo) and convert them to mono.

zrtstr Command line application for checking WAV-files for identical channels, detecting faux-stereo files generated by some audio-editing software an

A crate to convert bytes to something more useable and the other way around in a way Compatible with the Confluent Schema Registry. Supporting Avro, Protobuf, Json schema, and both async and blocking.
A crate to convert bytes to something more useable and the other way around in a way Compatible with the Confluent Schema Registry. Supporting Avro, Protobuf, Json schema, and both async and blocking.

#schema_registry_converter This library provides a way of using the Confluent Schema Registry in a way that is compliant with the Java client. The rel

tai (Terminal Ascii Image) tool to convert images to ascii written in Rust
tai (Terminal Ascii Image) tool to convert images to ascii written in Rust

TAI Terminal Ascii Image A tool to convert images to ascii art written in Rust 🦀 Notes This tool is still in development stage. Contributions All Con

Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format.
Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format.

RDR2 Screenshot converter Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format. QuickStart Just download the executable fi

 Obsidian Plugin: Convert a URL into markdown
Obsidian Plugin: Convert a URL into markdown

Obsidian Plugin: Convert a URL into markdown Transforms a URL to markdown view if the website allows it. Installation Available in the community plugi

Rust implementation to simply convert between coordinate systems

GeoMorph Simple conversion between different coordinate systems without external wrappers

A crate using DeepSpeech bindings to convert mic audio from speech to text

DS-TRANSCRIBER Need an Offline Speech To Text converter? Records your mic, and returns a String containing what was said. Features Begins transcriptio

Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes
Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes

What is Lust? Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes with scaling in mind.

A rust script to convert a better bibtex json file from Zotero into nice organised notes in Obsidian

Zotero to Obsidian script This is a script that takes a better bibtex JSON file exported by Zotero and generates an organised collection of reference

Convert VSCode themes to (Neo)Vim colorschemes
Convert VSCode themes to (Neo)Vim colorschemes

Djanho is a prototype which tries to convert VSCode themes to (Neo)Vim colorschemes. Features Handling of VSCode RGBA colors Out of the box conversion

Convert your ascii diagram scribbles into happy little SVG

Svgbob Svgbob can create a nice graphical representation of your text diagrams. Svgbob provides a cli which takes text as an input and creates an svg

RBTC is cli to convert BTC to any currency and vice-versa.
RBTC is cli to convert BTC to any currency and vice-versa.

RBTC RBTC is cli to convert BTC to any currency and vice-versa. Building for source For build the binary just: $ cargo build To run as debug, just run

docx-you-want is a tool to convert a PDF document into a .docx file

ddocx-you-want is a tool to convert a PDF document into a .docx file ... in an unusual way. Since these two formats are inherently differ

convert markdown headers to graph
convert markdown headers to graph

Rust Markdown to graph This program converts a Markdown file into a graph. For now, it creates .dot file which graphviz uses to build graph. It transl

Convert Sketchbook Tiff Files to Open Raster Images

SketchbookTiffConverter Convert Sketchbook Tiff Files to Open Raster Images and retain layer information. This is a command line program that will con

Convert timestamps to local times

rizzy All in a tizzy over timestamps? rizzy is a UNIX filter that will convert UTC timestamps into the timestamp of your choosing. Example Before: $ c

CLI tool to convert numbers from one base to another

changebase A CLI tool for changing the base of numbers. changebase -h numeric base converter USAGE: changebase [FLAGS] [OPTIONS] value FLAG

Rust library to convert RGB 24-bit colors into ANSI 256 (8-bit) color codes with zero dependencies and at compile-time.
Rust library to convert RGB 24-bit colors into ANSI 256 (8-bit) color codes with zero dependencies and at compile-time.

rgb2ansi256 rgb2ansi256 is a small Rust library to convert RGB 24-bit colors into ANSI 256 (8-bit) color codes with zero dependencies and const fn. Th

Comments
  • build(deps): bump h2 from 0.3.15 to 0.3.17

    build(deps): bump h2 from 0.3.15 to 0.3.17

    Bumps h2 from 0.3.15 to 0.3.17.

    Release notes

    Sourced from h2's releases.

    v0.3.17

    What's Changed

    • Add Error::is_library() method to check if the originated inside h2.
    • Add max_pending_accept_reset_streams(usize) option to client and server builders.
    • Fix theoretical memory growth when receiving too many HEADERS and then RST_STREAM frames faster than an application can accept them off the queue. (CVE-2023-26964)

    v0.3.16

    What's Changed

    • Set Protocol extension on requests when received Extended CONNECT requests.
    • Remove B: Unpin + 'static bound requiremented of bufs
    • Fix releasing of frames when stream is finished, reducing memory usage.
    • Fix panic when trying to send data and connection window is available, but stream window is not.
    • Fix spurious wakeups when stream capacity is not available.

    New Contributors

    Changelog

    Sourced from h2's changelog.

    0.3.17 (April 13, 2023)

    • Add Error::is_library() method to check if the originated inside h2.
    • Add max_pending_accept_reset_streams(usize) option to client and server builders.
    • Fix theoretical memory growth when receiving too many HEADERS and then RST_STREAM frames faster than an application can accept them off the queue. (CVE-2023-26964)

    0.3.16 (February 27, 2023)

    • Set Protocol extension on requests when received Extended CONNECT requests.
    • Remove B: Unpin + 'static bound requiremented of bufs
    • Fix releasing of frames when stream is finished, reducing memory usage.
    • Fix panic when trying to send data and connection window is available, but stream window is not.
    • Fix spurious wakeups when stream capacity is not available.
    Commits
    • af4bcac v0.3.17
    • d3f37e9 feat: add max_pending_accept_reset_streams(n) options
    • 5bc8e72 fix: limit the amount of pending-accept reset streams
    • 8088ca6 feat: add Error::is_library method
    • 481c31d chore: Use Cargo metadata for the MSRV build job
    • d3d50ef chore: Replace unmaintained/outdated GitHub Actions
    • 45b9bcc chore: set rust-version in Cargo.toml (#664)
    • b9dcd39 v0.3.16
    • 96caf4f Add a message for EOF-related broken pipe errors (#615)
    • 7323190 Avoid spurious wakeups when stream capacity is not available (#661)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies 
    opened by dependabot[bot] 0
  • add location option

    add location option

    Hi I just want to add the location option to the code It probably does not do much besides replacing the url, but the thing is a curl generated by Postman always have the --location option, which I think is something to think about. Not that versed in Rust and Pest yet, so please improve my code if able. Also, I just add the ---request option along with the -X And should the curl request have data but it is a GET,it should be automatically converted to a POST. Thank you.

    opened by ffleader1 0
Owner
Tyr Chen
father, programming enthusiast, author and entrepreneur.
Tyr Chen
Minimalist pedantic command line parser

Lexopt Lexopt is an argument parser for Rust. It tries to have the simplest possible design that's still correct. It's so simple that it's a bit tedio

Jan Verbeek 155 Dec 28, 2022
Custom implementation of Curl - Build Your Own curl

Build Your Own curl We are going to build curl from scratch by accepting the coding challenge posted on Coding Challenges FYI. Before moving ahead, yo

Praveen Chaudhary 15 Jun 7, 2024
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions

websocat Netcat, curl and socat for WebSockets. Examples Connect to public echo server $ websocat ws://echo.websocket.org 123 123 ABC ABC Serve and c

Vitaly Shukela 5k Jan 4, 2023
rurl is like curl but with a json configuration file per request

rurl rurl is a curl-like cli tool made in rust, the difference is that it takes its params from a json file so you can have all different requests sav

Bruno Ribeiro da Silva 6 Sep 10, 2022
A curl(libcurl) mod for rust.

curl Master Dev A lightweight Curl-wrapper for using (mostly) HTTP from Rust. While there are a couple of Rust HTTP libraries like rust-http and its s

Valerii Hiora 2 Sep 14, 2016
JiaShiwen 12 Nov 5, 2022
This is a simple command line application to convert bibtex to json written in Rust and Python

bibtex-to-json This is a simple command line application to convert bibtex to json written in Rust and Python. Why? To enable you to convert very big

null 3 Mar 23, 2022
hj is a command line tool to convert HTTP/1-style text into JSON

hj hj is a command line tool to convert HTTP/1-style text into JSON. This command is inspired by yusukebe/rj, which is a standalone HTTP client that s

FUJI Goro 10 Aug 21, 2022
Command line linguistic tools: display pronunciation, convert between regional norms of orthography

Command line linguistic tools: display pronunciation, convert between regional norms of orthography; support for multiple modern and ancient languages: English, Latin, Polish, Quechua, Tikuna

Piotr Bajdek 7 Nov 28, 2022
Command line tool to convert env variables beginning with user to a htpasswd file

envhtp This command line tool converts environment variables whose keys start with "user_" into htpasswd compatible username/password pairs. The goal

Florian Neumann 1 Apr 5, 2022