class Sekken::HTTPClient

Attributes

client[R]

Public: Returns the HTTPClient instance to configure.

Public Class Methods

new() click to toggle source
# File lib/sekken/httpclient.rb, line 6
def initialize
  @client = ::HTTPClient.new
end

Public Instance Methods

get(url) click to toggle source

Public: Executes an HTTP GET request to a given url.

Returns the raw HTTP response body as a String.

# File lib/sekken/httpclient.rb, line 16
def get(url)
  request(:get, url, {}, nil)
end
post(url, headers, body) click to toggle source

Public: Executes an HTTP POST request to a given url with headers and body.

Returns the raw HTTP response body as a String.

# File lib/sekken/httpclient.rb, line 23
def post(url, headers, body)
  request(:post, url, headers, body)
end

Private Instance Methods

request(method, url, headers, body) click to toggle source
# File lib/sekken/httpclient.rb, line 29
def request(method, url, headers, body)
  response = @client.request(method, url, nil, body, headers)
  response.content
end