class Net::HTTP

TODO Implement HTTP with jQuery for use in Glimmer DSL for Opal TODO Re-Implement in Fetch in the future Note: ignore Protocol superclass for now

Public Class Methods

get(uri, path_and_params) click to toggle source
# File lib/net/http.rb, line 39
def get(uri, path_and_params)
  uri = File.join(uri, path_and_params)
  uri = "#{`window.location.protocol`}//#{uri}" unless uri.start_with?('http:') || uri.start_with?('https:') # TODO refactor repetitive code
  result = nil
  ::HTTP.get(uri, {async: false, dataType: 'text'}) do |response|
    result = response.body if response.ok?
  end
  result
end
post_form(uri, params) click to toggle source
# File lib/net/http.rb, line 30
def post_form(uri, params)
  uri = "#{`window.location.protocol`}//#{File.join(uri)}" unless uri.start_with?('http:') || uri.start_with?('https:') # TODO refactor repetitive code
  result = nil
  ::HTTP.post(uri, {async: false, dataType: 'text', data: params}) do |response|
    result = response.body if response.ok?
  end
  result
end