class Object
Public Instance Methods
blank?()
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 10 def blank? respond_to?(:empty?) ? empty? : !self end
format_request_options(request_opts)
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 79 def format_request_options request_opts body = nil if request_opts[:params] body = request_opts[:params].to_json else body = request_opts[:input] end return request, body end
header(key, value)
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 18 def header key, value @headers = Hash.new(0) if @headers == nil @headers[key] = value end
last_response()
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 23 def last_response return @response end
perform_delete_request(uri,request_opts)
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 74 def perform_delete_request uri,request_opts request = Net::HTTP::Delete.new(uri.request_uri) return request, format_request_options(request_opts) end
perform_put_request(uri,request_opts)
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 64 def perform_put_request uri,request_opts request = Net::HTTP::Put.new(uri.request_uri) return request, format_request_options(request_opts) end
present?()
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 14 def present? !blank? end
request(path,request_opts)
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 27 def request path,request_opts req = "#{$SERVER_PATH}" + path uri = URI.parse(req) http = Net::HTTP.new(uri.host, uri.port) if request_opts[:method] == :post request, body = send_post_request(uri, request_opts) elsif request_opts[:method] == :put request, body = perform_put_request(uri, request_opts) elsif request_opts[:method] == :get request = send_get_request(uri, request_opts) elsif request_opts[:method] == :delete request, body = perform_delete_request(uri, request_opts) end #do we have any headers to add? if @headers != nil @headers.each { |k,v| request.add_field(k, v) } @headers = nil end if req.include? "https" http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE @response = http.request(request,body) else http = Net::HTTP.new(uri.host, uri.port) @response = http.request(request,body) end end
send_get_request(uri,request_opts)
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 69 def send_get_request uri,request_opts request = Net::HTTP::Get.new(uri.request_uri) return request end
send_post_request(uri,request_opts)
click to toggle source
# File lib/cucumber/rest_api/http_client.rb, line 59 def send_post_request uri,request_opts request = Net::HTTP::Post.new(uri.request_uri) return request, format_request_options(request_opts) end