5 # Create a new Server object, +uri+ is the full URI of the server,
6 # eg. "http://localhost:8888"
11 @connection = Net::HTTP.new(@host, @port)
12 @connection.set_debug_output($stderr) if $debug
14 attr_accessor :host, :port, :connection
16 # Send a GET request to +path+
18 request(Net::HTTP::Get.new(path))
21 # Send a POST request to +path+ with the body payload of +data+
22 # +content_type+ is the Content-Type header to send along (defaults to
24 def post(path, data, content_type="application/json")
25 post = Net::HTTP::Post.new(path)
26 post["content-type"] = content_type
31 # Send a PUT request to +path+ with the body payload of +data+
32 # +content_type+ is the Content-Type header to send along (defaults to
34 def put(path, data, content_type="application/json")
35 put = Net::HTTP::Put.new(path)
36 put["content-type"] = content_type
41 # Send a DELETE request to +path+
43 req = Net::HTTP::Delete.new(path)
47 # send off a +req+ object to the host. req is a Net::Http:: request class
48 # (eg Net::Http::Get/Net::Http::Post etc)
50 connection.request(req)