diff --git a/src/Transport/Curl.php b/src/Transport/Curl.php index df98894a3..5547ec670 100644 --- a/src/Transport/Curl.php +++ b/src/Transport/Curl.php @@ -201,12 +201,14 @@ public function request($url, $headers = array(), $data = array(), $options = ar $response = $this->response_data; } - $this->process_response($response, $options); + if (true === $options['blocking']) { + // Need to remove the $this reference from the curl handle. + // Otherwise \WpOrg\Requests\Transport\Curl wont be garbage collected and the curl_close() will never be called. + curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, null); + curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, null); + } - // Need to remove the $this reference from the curl handle. - // Otherwise \WpOrg\Requests\Transport\Curl won't be garbage collected and the curl_close() will never be called. - curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, null); - curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, null); + $this->process_response($response, $options); return $this->headers; }