@@ -42,11 +42,7 @@ public function __construct() {
4242 throw new \ErrorException ('cURL library is not loaded ' );
4343 }
4444
45- $ this ->curl = curl_init ();
46- $ this ->setUserAgent (self ::USER_AGENT );
47- $ this ->setopt (CURLINFO_HEADER_OUT , TRUE );
48- $ this ->setopt (CURLOPT_HEADER , TRUE );
49- $ this ->setopt (CURLOPT_RETURNTRANSFER , TRUE );
45+ $ this ->init ();
5046 }
5147
5248 public function get ($ url , $ data = array ()) {
@@ -125,6 +121,25 @@ public function close() {
125121 curl_close ($ this ->curl );
126122 }
127123 }
124+
125+ public function reset () {
126+ $ this ->close ();
127+ $ this ->_cookies = array ();
128+ $ this ->_headers = array ();
129+ $ this ->error = FALSE ;
130+ $ this ->error_code = 0 ;
131+ $ this ->error_message = NULL ;
132+ $ this ->curl_error = FALSE ;
133+ $ this ->curl_error_code = 0 ;
134+ $ this ->curl_error_message = NULL ;
135+ $ this ->http_error = FALSE ;
136+ $ this ->http_status_code = 0 ;
137+ $ this ->http_error_message = NULL ;
138+ $ this ->request_headers = NULL ;
139+ $ this ->response_headers = NULL ;
140+ $ this ->response = NULL ;
141+ $ this ->init ();
142+ }
128143
129144 public function _exec () {
130145 $ this ->response = curl_exec ($ this ->curl );
@@ -155,4 +170,12 @@ public function _exec() {
155170 public function __destruct () {
156171 $ this ->close ();
157172 }
173+
174+ private function init () {
175+ $ this ->curl = curl_init ();
176+ $ this ->setUserAgent (self ::USER_AGENT );
177+ $ this ->setopt (CURLINFO_HEADER_OUT , TRUE );
178+ $ this ->setopt (CURLOPT_HEADER , TRUE );
179+ $ this ->setopt (CURLOPT_RETURNTRANSFER , TRUE );
180+ }
158181}
0 commit comments