Sha256: 0cd7d16bdee7a13f11cb39188390317c5062dc944fc8a9a68841a4a49b271bca

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

class Object
  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

  def perform_delete_request uri,request_opts
    request = Net::HTTP::Delete.new(uri.request_uri)
    body = nil
    if request_opts[:params]
      body = request_opts[:params].to_json
    else
      body = request_opts[:input]
    end
    return request, body
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
minke-generator-swift-0.5 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.4 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.2.2 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.2.1 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.2.0 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.1.8 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.1.7 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.1.6 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.1.4 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb
minke-generator-swift-0.1.0 lib/generators/swift/scaffold/_build/features/steps/cucumer_rest_monkey_patch.rb