Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

curlify

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curlify

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

The gem convert ruby requests(net/http) into curl command.

Installation

To install the gem use bundle or gem, see:

$ gem install curlify

or bundle:

$ bundle add curlify

Usage with faraday

Import curlify and faraday and perform curlify, see:

require 'faraday'
require 'curlify'

request = Faraday.new.build_request(:post) do |req|
  req.url 'http://127.0.0.1'
end

Curlify.new(request).to_curl # "curl -X POST -H 'User-Agent: Faraday v2.9.0'  http://127.0.0.1"

Usage with net/http

Import curlify, uri and net/http and perform curlify, see:

require 'json'
require 'uri'
require 'net/http'
require 'curlify'

uri = URI('https://httpbin.org/post')
request = Net::HTTP::Post.new(uri, { 'content-type': 'application/json' })
request.body = { title: 'Ruby is great :)' }.to_json

Curlify.new(request).to_curl # curl -X POST -H 'content-type: application/json' -H 'accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3' -H 'accept: */*' -H 'user-agent: Ruby' -H 'host: httpbin.org' -d '{"title":"Ruby is great :)"}' https://httpbin.org/post

Performing this curl command, we can see the following result:

{
  "args": {},
  "data": "{\"title\":\"Ruby is great :)\"}",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
    "Content-Length": "28",
    "Content-Type": "application/json",
    "Host": "httpbin.org",
    "User-Agent": "Ruby",
    "X-Amzn-Trace-Id": "Root=1-64f38ad0-444dbe403f03082e14ba1d62"
  },
  "json": {
    "title": "Ruby is great :)"
  },
  "origin": "xxx.xxx.xx.xx",
  "url": "https://httpbin.org/post"
}

FAQs

Package last updated on 28 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc