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



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

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



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

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)


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

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]
  http = http.start
  yield(req, http) if block_given?
  res = http.post(url_path, data, header) 
  res
end

#proxyObject



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

def proxy
  #TODO Uncomment the following line of code and comment the next line of code BEFORE RELEASE
  # @http_web_proxy || Net::HTTP
  @http_web_proxy || Net::HTTP::Proxy('itgproxy.redmond.corp.microsoft.com', '80')
end

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

Yields:

  • (req, http)


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

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