Sha256: 61162bf5ddd82847db25c295ce2f65eda6fc8b52fd249b5e616d286e3477a25d

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

require 'httpclient'

class Sekken
  class HTTPClient

    def initialize
      @client = ::HTTPClient.new
    end

    # Public: Returns the HTTPClient instance to configure.
    attr_reader :client

    # Public: Executes an HTTP GET request to a given url.
    #
    # Returns the raw HTTP response body as a String.
    def get(url)
      request(:get, url, {}, nil)
    end

    # Public: Executes an HTTP POST request to a given url with headers and body.
    #
    # Returns the raw HTTP response body as a String.
    def post(url, headers, body)
      request(:post, url, headers, body)
    end

    private

    def request(method, url, headers, body)
      response = @client.request(method, url, nil, body, headers)
      response.content
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sekken-0.3.0 lib/sekken/httpclient.rb
sekken-0.2.0 lib/sekken/httpclient.rb
sekken-0.1.0 lib/sekken/httpclient.rb