Method: JSONRequest#delete

Defined in:
lib/foundation/JSONRequest.rb

#delete(url, username, password) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/foundation/JSONRequest.rb', line 92

def delete(url, username, password)
  uri=URI.parse(url)
  req = Net::HTTP::Delete.new(uri.request_uri)
  req.basic_auth username, password
  response=HTTPResponse.new()
  begin
    httpresponse = Net::HTTP.new(uri.host, uri.port).start { |http| http.request(req) }
    response.setCode(httpresponse.code)
    response.setContent(httpresponse.body)
    response.setContentType(httpresponse.header['Content-Type'])
    response.setLocation(httpresponse.header['Location'])
  rescue => e
    print 'exception handled'
  end
  return response
end