module SkypeCheck::HTTPService

Public Class Methods

http_query(username) click to toggle source
# File lib/skype_check/http_service.rb, line 10
def http_query(username) 
  begin
    #setup uri object with username param
    uri = URI(SkypeCheck.configuration.username_validator_endpoint)
    param = { new_username: username }
    uri.query = URI.encode_www_form(param)

    #build a request object
    http = Net::HTTP.new(uri.host, uri.port)
    if uri.kind_of? URI::HTTPS
      http.use_ssl = true
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end

    request = Net::HTTP::Get.new(uri.request_uri)
    http.request(request)
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, SocketError => e
    raise SkypeCheck::QueryError.new(e)
  end
end

Private Instance Methods

http_query(username) click to toggle source
# File lib/skype_check/http_service.rb, line 10
def http_query(username) 
  begin
    #setup uri object with username param
    uri = URI(SkypeCheck.configuration.username_validator_endpoint)
    param = { new_username: username }
    uri.query = URI.encode_www_form(param)

    #build a request object
    http = Net::HTTP.new(uri.host, uri.port)
    if uri.kind_of? URI::HTTPS
      http.use_ssl = true
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end

    request = Net::HTTP::Get.new(uri.request_uri)
    http.request(request)
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, SocketError => e
    raise SkypeCheck::QueryError.new(e)
  end
end