Class: Nrcmd::Http
- Inherits:
-
Object
- Object
- Nrcmd::Http
- Defined in:
- lib/nrcmd/util/http.rb
Class Method Summary collapse
- .delete(uri_str, _header = {}, param = "") ⇒ Object
- .get(uri_str, _header = {}, param = "") ⇒ Object
- .put(uri_str, _header = {}, param = "") ⇒ Object
Class Method Details
.delete(uri_str, _header = {}, param = "") ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/nrcmd/util/http.rb', line 44 def delete(uri_str, _header={}, param="") uri = URI.parse(uri_str + '?' + param) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.set_debug_output $stderr if Nrcmd.log_level == "DEBUG" header = @header.merge _header req = Net::HTTP::Delete.new(uri.request_uri, initheader = header) res = https.start { https.request(req) } if res.code == '200' return res else (res) end end |
.get(uri_str, _header = {}, param = "") ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/nrcmd/util/http.rb', line 9 def get(uri_str, _header={}, param="") uri = URI.parse(uri_str + '?' + param) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.set_debug_output $stderr if Nrcmd.log_level == "DEBUG" header = @header.merge _header req = Net::HTTP::Get.new(uri.request_uri, initheader = header) res = https.start { https.request(req) } if res.code == '200' return res else (res) end end |
.put(uri_str, _header = {}, param = "") ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/nrcmd/util/http.rb', line 26 def put(uri_str, _header={}, param="") uri = URI.parse(uri_str) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.set_debug_output $stderr if Nrcmd.log_level == "DEBUG" header = @header.merge _header req = Net::HTTP::Put.new(uri.request_uri, initheader = header) req.body = param res = https.start { https.request(req) } if res.code == '200' return res else (res) end end |