From 6b7f09eba675679d5ea84ed33e85fa9d5c62a30d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 21:55:36 -0400 Subject: [PATCH] add get to curl client --- lib/curlclient.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/curlclient.php b/lib/curlclient.php index e027102e36..f45c3c2f4a 100644 --- a/lib/curlclient.php +++ b/lib/curlclient.php @@ -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() -- 2.39.5