module Roxanne::HTTPSupport

Attributes

disable_certificate_verification[RW]
host[RW]
password[RW]
path[RW]
port[RW]
use_ssl[RW]
username[RW]

Protected Instance Methods

accept() click to toggle source

Override if needed to force a particular format : application/json, text/xml, etc

# File lib/roxanne/http_support.rb, line 38
def accept
  '*'
end

Private Instance Methods

complete_path() click to toggle source
# File lib/roxanne/http_support.rb, line 32
def complete_path
  @path
end
fetch_response() click to toggle source
# File lib/roxanne/http_support.rb, line 14
def fetch_response
  connection = ::Net::HTTP.new(@host, @port)
  connection.use_ssl=@use_ssl
  if @disable_certificate_verification
    # TODO retrieve the certificate from the remote system, see http://redcorundum.blogspot.com/2008/03/ssl-certificates-and-nethttps.html
    # Avoid issues with autosigned certificates
    connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end
  request = Net::HTTP::Get.new(complete_path, {'Accept'=>accept})

  # TODO Authentication
  unless (username.nil? && password.nil?)
    request.basic_auth username, password
  else
  end
  connection.request(request)
end