Sha256: b4c2ce9c33e3191b77594c58cb983600d3d94084911328438b717159dcdf2371

Contents?: true

Size: 499 Bytes

Versions: 3

Compression:

Stored size: 499 Bytes

Contents

# frozen_string_literal: true

require 'curb'

# namespace
module Curlable
  def get(url:, headers: {})
    Curl::Easy.http_get(url) do |http|
      http.follow_location = true
      headers.each { |k, v| http.headers[k] = v }
    end.body_str
  end

  def post(url:, headers: {}, params: {})
    Curl::Easy.http_post("#{url}?#{Curl.postalize(params)}", Curl.postalize(params)) do |http|
      http.follow_location = true
      headers.each { |k, v| http.headers[k] = v }
    end.body_str
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spn2-0.2.0 lib/curlable.rb
spn2-0.1.2 lib/curlable.rb
spn2-0.1.1 lib/curlable.rb