Module: DotNetServices::HTTPRequests

Included in:
MessageBuffer, SamlTokenProvider, SimpleWebTokenProvider, TokenProvider
Defined in:
lib/service_bus/requests.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ToHash

Instance Method Summary collapse

Instance Method Details

#delete(url, options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/service_bus/requests.rb', line 56

def delete(url, options = {})
  header = options[:header] if options[:header]
  url = URI.parse(url)
  url_path = (url.query && url.query != '') ? (url.path + '?' + url.query) : url.path
  req = Net::HTTP::Delete.new(url_path, header)
  req.basic_auth options[:http_username], options[:http_password] if options[:http_username] && options[:http_password]
  res = proxy.start(url.host, url.port) do |http| 
    yield(req, http) if block_given?
    http.request(req)
  end
  res
end

#get(url, options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/service_bus/requests.rb', line 44

def get(url, options = {})
  header = options[:header] if options[:header]
  url = URI.parse(url)
  req = Net::HTTP::Get.new(url.path, header)
  req.basic_auth options[:http_username], options[:http_password] if options[:http_username] && options[:http_password]
  res = proxy.start(url.host, url.port) do |http| 
    yield(req, http) if block_given?
    http.request(req)
  end
  res
end

#post(url, data, options = {}) {|req, http| ... } ⇒ Object

Yields:

  • (req, http)


69
70
71
72
73
74
75
76
77
78
79
# File 'lib/service_bus/requests.rb', line 69

def post(url, data, options = {})
  header = options[:header] if options[:header]
  url = URI.parse(url)
  url_path = (url.query && url.query != '') ? (url.path + '?' + url.query) : url.path
  http = proxy.new(url.host, url.port)
  http.use_ssl = true if options[:use_ssl]
  yield(req, http) if block_given?
  http = http.start
  res = http.post(url_path, data, header) 
  res
end

#proxyObject



40
41
42
# File 'lib/service_bus/requests.rb', line 40

def proxy
  @http_web_proxy || Net::HTTP
end

#put(url, data, options = {}) {|req, http| ... } ⇒ Object

Yields:

  • (req, http)


81
82
83
84
85
86
87
88
89
90
# File 'lib/service_bus/requests.rb', line 81

def put(url , data, options = {})
 header = options[:header] if options[:header]
 url = URI.parse(url)
 url_path = (url.query && url.query != '') ? (url.path + '?' + url.query) : url.path
 http = proxy.new(url.host, url.port)
 yield(req, http) if block_given?
 http = http.start
 res = http.put(url_path, data, header) 
 res
end