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
- #delete(url, options = {}) ⇒ Object
- #get(url, options = {}) ⇒ Object
- #post(url, data, options = {}) {|req, http| ... } ⇒ Object
- #proxy ⇒ Object
- #put(url, data, options = {}) {|req, http| ... } ⇒ Object
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, = {}) header = [:header] if [: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 [:http_username], [:http_password] if [:http_username] && [: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, = {}) header = [:header] if [:header] url = URI.parse(url) req = Net::HTTP::Get.new(url.path, header) req.basic_auth [:http_username], [:http_password] if [:http_username] && [: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
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/service_bus/requests.rb', line 69 def post(url, data, = {}) header = [:header] if [: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 [:use_ssl] yield(req, http) if block_given? http = http.start res = http.post(url_path, data, header) res end |
#proxy ⇒ Object
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
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/service_bus/requests.rb', line 81 def put(url , data, = {}) header = [:header] if [: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 |