<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1 @@
-curl_cookie.txt
\ No newline at end of file
+lib/curl_cookie.txt
\ No newline at end of file</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,110 +1,202 @@
 &lt;?php
 
-# Curl, CurlResponse
-#
-# Author  Sean Huber - shuber@huberry.com
-# Date    May 2008
-#
-# A basic CURL wrapper for PHP
-#
-# See the README for documentation/examples or http://php.net/curl for more information about the libcurl extension for PHP
-
-class Curl 
-{
+/**
+ * A basic CURL wrapper
+ *
+ * See the README for documentation/examples or http://php.net/curl for more information about the libcurl extension for PHP
+ *
+ * @package curl
+ * @author Sean Huber &lt;shuber@huberry.com&gt;
+**/
+class Curl {
+    
     public $cookie_file;
+    public $follow_redirects = true;
     public $headers = array();
     public $options = array();
-    public $referer = '';
-    public $user_agent = '';
-
+    public $referer;
+    public $user_agent;
+    
     protected $error = '';
-    protected $handle;
-
-
-    public function __construct() 
-    {
-        $this-&gt;cookie_file = dirname(__FILE__).'/curl_cookie.txt';
-        $this-&gt;user_agent = isset($_SERVER['HTTP_USER_AGENT']) ?
-            $_SERVER['HTTP_USER_AGENT'] :
-            'Curl/PHP ' . PHP_VERSION . ' (http://github.com/shuber/curl/)';
+    protected $request;
+    
+    public function __construct() {
+        $this-&gt;cookie_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'curl_cookie.txt';
+        $this-&gt;user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Curl/PHP '.PHP_VERSION.' (http://github.com/shuber/curl)';
     }
-
-    public function delete($url, $vars = array()) 
-    {
+    
+    /**
+     * Makes an HTTP DELETE request to the specified $url with an optional array or string of $vars
+     *
+     * Returns a CurlResponse object if the request was successful, false otherwise
+     *
+     * @param string $url
+     * @param array|string $vars 
+     * @return CurlResponse object
+    **/
+    public function delete($url, $vars = array()) {
         return $this-&gt;request('DELETE', $url, $vars);
     }
-
-    public function error() 
-    {
+    
+    /**
+     * Returns the error string of the current request if one occurred
+     *
+     * @return string
+    **/
+    public function error() {
         return $this-&gt;error;
     }
-
-    public function get($url, $vars = array()) 
-    {
+    
+    /**
+     * Makes an HTTP GET request to the specified $url with an optional array or string of $vars
+     *
+     * Returns a CurlResponse object if the request was successful, false otherwise
+     *
+     * @param string $url
+     * @param array|string $vars 
+     * @return CurlResponse
+    **/
+    public function get($url, $vars = array()) {
         if (!empty($vars)) {
             $url .= (stripos($url, '?') !== false) ? '&amp;' : '?';
-            $url .= http_build_query($vars, '', '&amp;');
+            $url .= (is_string($vars)) ? $vars : http_build_query($vars, '', '&amp;');
         }
         return $this-&gt;request('GET', $url);
     }
-
-    public function post($url, $vars = array()) 
-    {
+    
+    /**
+     * Makes an HTTP HEAD request to the specified $url with an optional array or string of $vars
+     *
+     * Returns a CurlResponse object if the request was successful, false otherwise
+     *
+     * @param string $url
+     * @param array|string $vars
+     * @return CurlResponse
+    **/
+    public function head($url, $vars = array()) {
+        return $this-&gt;request('HEAD', $url, $vars);
+    }
+    
+    /**
+     * Makes an HTTP POST request to the specified $url with an optional array or string of $vars
+     *
+     * @param string $url
+     * @param array|string $vars 
+     * @return CurlResponse|boolean
+    **/
+    public function post($url, $vars = array()) {
         return $this-&gt;request('POST', $url, $vars);
     }
-
-    public function put($url, $vars = array()) 
-    {
+    
+    /**
+     * Makes an HTTP PUT request to the specified $url with an optional array or string of $vars
+     *
+     * Returns a CurlResponse object if the request was successful, false otherwise
+     *
+     * @param string $url
+     * @param array|string $vars 
+     * @return CurlResponse|boolean
+    **/
+    public function put($url, $vars = array()) {
         return $this-&gt;request('PUT', $url, $vars);
     }
-
-    protected function request($method, $url, $vars = array()) 
-    {
-        $this-&gt;handle = curl_init();
+    
+    /**
+     * Makes an HTTP request of the specified $method to a $url with an optional array or string of $vars
+     *
+     * Returns a CurlResponse object if the request was successful, false otherwise
+     *
+     * @param string $method
+     * @param string $url
+     * @param array|string $vars
+     * @return CurlResponse|boolean
+    **/
+    function request($method, $url, $vars = array()) {
+        $this-&gt;error = '';
+        $this-&gt;request = curl_init();
+        if (is_array($vars)) $vars = http_build_query($vars, '', '&amp;');
+        
+        $this-&gt;set_request_method($method);
+        $this-&gt;set_request_options($url, $vars);
+        $this-&gt;set_request_headers();
+        
+        $response = curl_exec($this-&gt;request);
+        
+        if ($response) {
+            $response = new CurlResponse($response);
+        } else {
+            $this-&gt;error = curl_errno($this-&gt;request).' - '.curl_error($this-&gt;request);
+        }
+        
+        curl_close($this-&gt;request);
         
-        # Determine the request method and set the correct CURL option
+        return $response;
+    }
+    
+    /**
+     * Formats and adds custom headers to the current request
+     *
+     * @return void
+     * @access protected
+    **/
+    protected function set_request_headers() {
+        $headers = array();
+        foreach ($this-&gt;headers as $key =&gt; $value) {
+            $headers[] = $key.': '.$value;
+        }
+        curl_setopt($this-&gt;request, CURLOPT_HTTPHEADER, $headers);
+    }
+    
+    /**
+     * Set the associated CURL options for a request method
+     *
+     * @param string $method
+     * @return void
+     * @access protected
+    **/
+    protected function set_request_method($method) {
         switch ($method) {
+            case 'HEAD':
+                curl_setopt($this-&gt;request, CURLOPT_NOBODY, true);
+                break;
             case 'GET':
-                curl_setopt($this-&gt;handle, CURLOPT_HTTPGET, true);
+                curl_setopt($this-&gt;request, CURLOPT_HTTPGET, true);
                 break;
             case 'POST':
-                curl_setopt($this-&gt;handle, CURLOPT_POST, true);
+                curl_setopt($this-&gt;request, CURLOPT_POST, true);
                 break;
             default:
-                curl_setopt($this-&gt;handle, CURLOPT_CUSTOMREQUEST, $method);
+                curl_setopt($this-&gt;request, CURLOPT_CUSTOMREQUEST, $method);
         }
+    }
+    
+    /**
+     * Sets the CURLOPT options for the current request
+     *
+     * @param string $url
+     * @param string $vars
+     * @return void
+     * @access protected
+    **/
+    protected function set_request_options($url, $vars) {
+        curl_setopt($this-&gt;request, CURLOPT_URL, $url);
+        if (!empty($vars)) curl_setopt($this-&gt;request, CURLOPT_POSTFIELDS, $vars);
         
         # Set some default CURL options
-        curl_setopt($this-&gt;handle, CURLOPT_COOKIEFILE, $this-&gt;cookie_file);
-        curl_setopt($this-&gt;handle, CURLOPT_COOKIEJAR, $this-&gt;cookie_file);
-        curl_setopt($this-&gt;handle, CURLOPT_FOLLOWLOCATION, true);
-        curl_setopt($this-&gt;handle, CURLOPT_HEADER, true);
-        if (!empty($vars)) curl_setopt($this-&gt;handle, CURLOPT_POSTFIELDS, (is_array($vars) ? http_build_query($vars, '', '&amp;') : $vars));
-        curl_setopt($this-&gt;handle, CURLOPT_REFERER, $this-&gt;referer);
-        curl_setopt($this-&gt;handle, CURLOPT_RETURNTRANSFER, true);
-        curl_setopt($this-&gt;handle, CURLOPT_URL, $url);
-        curl_setopt($this-&gt;handle, CURLOPT_USERAGENT, $this-&gt;user_agent);
-        
-        # Format custom headers for this request and set CURL option
-        $headers = array();
-        foreach ($this-&gt;headers as $key =&gt; $value) {
-            $headers[] = $key.': '.$value;
+        curl_setopt($this-&gt;request, CURLOPT_HEADER, true);
+        curl_setopt($this-&gt;request, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($this-&gt;request, CURLOPT_USERAGENT, $this-&gt;user_agent);
+        if ($this-&gt;cookie_file) {
+            curl_setopt($this-&gt;request, CURLOPT_COOKIEFILE, $this-&gt;cookie_file);
+            curl_setopt($this-&gt;request, CURLOPT_COOKIEJAR, $this-&gt;cookie_file);
         }
-        curl_setopt($this-&gt;handle, CURLOPT_HTTPHEADER, $headers);
+        if ($this-&gt;follow_redirects) curl_setopt($this-&gt;request, CURLOPT_FOLLOWLOCATION, true);
+        if ($this-&gt;referer) curl_setopt($this-&gt;request, CURLOPT_REFERER, $this-&gt;referer);
         
         # Set any custom CURL options
         foreach ($this-&gt;options as $option =&gt; $value) {
-            curl_setopt($this-&gt;handle, constant('CURLOPT_'.str_replace('CURLOPT_', '', strtoupper($option))), $value);
+            curl_setopt($this-&gt;request, constant('CURLOPT_'.str_replace('CURLOPT_', '', strtoupper($option))), $value);
         }
-        
-        $response = curl_exec($this-&gt;handle);
-        if ($response) {
-            $response = new CurlResponse($response);
-        } else {
-            $this-&gt;error = curl_errno($this-&gt;handle).' - '.curl_error($this-&gt;handle);
-        }
-        curl_close($this-&gt;handle);
-        return $response;
     }
 
 }
\ No newline at end of file</diff>
      <filename>lib/curl.php</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,4 @@
 require 'curl.php';
 $curl = new Curl;
 
-print_r($curl-&gt;get('google.com')-&gt;headers);
-
-?&gt;
\ No newline at end of file
+print_r($curl-&gt;get('google.com')-&gt;headers);
\ No newline at end of file</diff>
      <filename>test.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0f3d840505a74eb083dcdae8329f00c9b710a735</id>
    </parent>
  </parents>
  <author>
    <name>Sean Huber</name>
    <email>shuber@huberry.com</email>
  </author>
  <url>http://github.com/shuber/curl/commit/848b2d5fa5f4c5aac7cda5cce1c2cc4c5b5f6c79</url>
  <id>848b2d5fa5f4c5aac7cda5cce1c2cc4c5b5f6c79</id>
  <committed-date>2009-09-05T13:11:51-07:00</committed-date>
  <authored-date>2009-09-05T13:11:51-07:00</authored-date>
  <message>Refactor</message>
  <tree>26a49caf8fda62d5b0e9a50b20ab0d454183b977</tree>
  <committer>
    <name>Sean Huber</name>
    <email>shuber@huberry.com</email>
  </committer>
</commit>
