<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,6 +2,8 @@ require 'rubygems'
 require 'extlib'
 require 'json'
 require 'uuid'
+gem 'taf2-curb'
+require 'curb'
 
 require 'cgi'
 require 'net/http'</diff>
      <filename>lib/relaxdb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,64 +3,66 @@ module RelaxDB
   class HTTP_404 &lt; StandardError; end
   class HTTP_409 &lt; StandardError; end
   class HTTP_412 &lt; StandardError; end
-
+  
   class Server
-        
+    class Response
+      attr_reader :body
+      def initialize body
+        @body = body
+      end
+    end
+    
     def initialize(host, port)
-      @host = host
-      @port = port
+      @host, @port = host, port
     end
-
+    
     def delete(uri)
-      request(Net::HTTP::Delete.new(uri))
+      request(uri, 'delete'){ |c| c.http_delete}
     end
 
     def get(uri)
-      request(Net::HTTP::Get.new(uri))
+      request(uri, 'get'){ |c| c.http_get}
     end
 
     def put(uri, json)
-      req = Net::HTTP::Put.new(uri)
-      req[&quot;content-type&quot;] = &quot;application/json&quot;
-      req.body = json
-      request(req)
+      request(uri, 'put') do |c| 
+        c.headers['content-type'] = 'application/json'
+        c.http_put json
+      end
     end
 
     def post(uri, json)
-      req = Net::HTTP::Post.new(uri)
-      req[&quot;content-type&quot;] = &quot;application/json&quot;
-      req.body = json
-      request(req)
+      request(uri, 'post') do |c| 
+        c.headers['content-type'] = 'application/json'
+        c.http_post json
+      end
     end
 
-    def request(req)
-      res = Net::HTTP.start(@host, @port) {|http|
-        http.request(req)
-      }
-      if (not res.kind_of?(Net::HTTPSuccess))
-        handle_error(req, res)
+    def request(uri, method)
+      c = Curl::Easy.new &quot;http://#{@host}:#{@port}#{uri}&quot;
+      yield c
+      
+      if c.response_code &lt; 200 || c.response_code &gt;= 300
+        status_line = c.header_str.split('\r\n').first
+        msg = &quot;#{c.response_code}:#{status_line}\nMETHOD:#{method}\nURI:#{uri}\n#{c.body_str}&quot;
+        begin
+          klass = RelaxDB.const_get(&quot;HTTP_#{c.response_code}&quot;)
+          e = klass.new(msg)
+        rescue
+          e = RuntimeError.new(msg)
+        end
+
+        raise e
       end
-      res
-    end
-    
+      Response.new c.body_str
+    end  
+
     def to_s
       &quot;http://#{@host}:#{@port}/&quot;
     end
-    
-    private
 
-    def handle_error(req, res)
-      msg = &quot;#{res.code}:#{res.message}\nMETHOD:#{req.method}\nURI:#{req.path}\n#{res.body}&quot;
-      begin
-        klass = RelaxDB.const_get(&quot;HTTP_#{res.code}&quot;)
-        e = klass.new(msg)
-      rescue
-        e = RuntimeError.new(msg)
-      end
-
-      raise e
-    end
   end
+  
       
   class CouchDB
 </diff>
      <filename>lib/relaxdb/server.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a89edb9ef7d273c860c61dfd0c4c8397aa0bf2d0</id>
    </parent>
  </parents>
  <author>
    <name>Frederick Cheung</name>
    <login>fcheung</login>
    <email>frederick.cheung@gmail.com</email>
  </author>
  <url>http://github.com/fcheung/relaxdb/commit/92f7ff93130e8286e379a6953293f3a727e8bf0b</url>
  <id>92f7ff93130e8286e379a6953293f3a727e8bf0b</id>
  <committed-date>2009-04-10T12:32:37-07:00</committed-date>
  <authored-date>2009-04-10T12:32:37-07:00</authored-date>
  <message>Use taf2-curb instead of net/http: much nippier</message>
  <tree>e2ade51868125f124567fc1429cf0a5132295e0b</tree>
  <committer>
    <name>Frederick Cheung</name>
    <login>fcheung</login>
    <email>frederick.cheung@gmail.com</email>
  </committer>
</commit>
