]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add get to curl client
authorEvan Prodromou <evan@status.net>
Wed, 16 Sep 2009 01:55:36 +0000 (21:55 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 16 Sep 2009 01:55:36 +0000 (21:55 -0400)
lib/curlclient.php

index e027102e36641c46e191399b1e843596cdebcdcd..f45c3c2f4a01c4bd7e88b88a20090e160e7bce18 100644 (file)
@@ -60,8 +60,31 @@ class CurlClient extends HTTPClient
         curl_setopt_array($ch,
                           array(CURLOPT_NOBODY => true));
 
+        if (!is_null($headers)) {
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+        }
+
+        $result = curl_exec($ch);
+
+        curl_close($ch);
+
+        return $this->parseResults($result);
+    }
+
+    function get($url, $headers=null)
+    {
+        $ch = curl_init($url);
+
+        $this->setup($ch);
+
+        if (!is_null($headers)) {
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+        }
+
         $result = curl_exec($ch);
 
+        curl_close($ch);
+
         return $this->parseResults($result);
     }
 
@@ -70,8 +93,7 @@ class CurlClient extends HTTPClient
         curl_setopt_array($ch,
                           array(CURLOPT_USERAGENT, $this->userAgent(),
                                 CURLOPT_HEADER => true,
-                                CURLOPT_RETURNTRANSFER => true,
-                                CURLOPT_HTTPHEADER => $headers));
+                                CURLOPT_RETURNTRANSFER => true));
     }
 
     function userAgent()