diff options
author | Evan Prodromou <evan@status.net> | 2009-09-15 21:55:36 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-09-15 21:55:36 -0400 |
commit | 6b7f09eba675679d5ea84ed33e85fa9d5c62a30d (patch) | |
tree | 9000910d4e6aa2cddafd88f60ac50d478d66e36e | |
parent | 9a9a0ae56f5ae65144e6da5014859b1e30044f8b (diff) |
add get to curl client
-rw-r--r-- | lib/curlclient.php | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/curlclient.php b/lib/curlclient.php index e027102e3..f45c3c2f4 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() |