Welcome Guest, Not a member yet? Register   Sign In

HI there CI guys. You're all doing a great job and am looking forward to the production product. 

I've been working on some practice projects  and I ran into an issue using cURL. 

My objective is to get the contents of a webpage and extract the title. Whenever I tried to use the cURL library to access an external page I would get the follow error message in my log. 

curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE*

So I started digging around and I think I discovered what was causing my issue. The issue in the CURLRequest.php file in the function setCURLOptions(). Please see the following section of code currently starting around line 676 of the file. 

  if (isset($config['debug']))
   $curl_options[CURLOPT_VERBOSE] = $config['debug'] === true ? 1 : 0;
   $curl_options[CURLOPT_STDERR]  = is_bool($config['debug']) ? fopen('php://output', 'w+') : $config['debug'];

The problem I'm having is that this runs even when I don't set the debug param in the curl request. See
$response = $client->request('GET', "http://something/something", [
     'auth' => ['user', 'pass']    

For now I have worked around this by commenting out line 78  where the 'debug' param is set by the class file. See

protected $config = [
  'timeout'         => 0.0,
  'connect_timeout' => 150,
  //'debug'           => false,
  'verify'          => true,

Another workaround was to change "php://output" to a file location so it doesn't open a stream. 

Anyways, either I am using your cURL library incorrectly or maybe there should be a different way to setting the debug format . 

Any feedback you guys can provide would be helpful. 

Oh and if you have any suggestions on how to use the CI cURL library (based on guzzle) to extract the title out of a webpage. I still haven't figured that out yet.

Cheers all. and thanks for all your hard work.

It looks like we should be checking not just if debug is a bool but if it's true.... Looks like a bug. I'll post an issue over at GitHub about this. Thanks for reporting!

Additionally, I'd like to ask about the getBody() function. $response->getBody() doesn't seem to return any content. I'm trying to return HTML file using the client request method. I can see the headers. I cannot see a body.
Does anyone have an example of returning html content to a response? I'm not sure if this is a bug or not. Can anyone confirm?


I just pushed a potential fix for the CurlRequest debug issue. Can you confirm it for me?

As for your other issue - I'm a little confused what you're trying to do? Can you be more specific.

Hi Kil. Sorry to report but I dont think I can test this properly afterall. I've had to change computers and my environment is limited to PHP 7.1 for now.

Thanks for looking at this. Maybe someone else can test?

Kil , where should I pull the updated files from?

The develop branch.

Still not working. Getting a SetOptArray error message.

This is the code Im trying to use.

$client = \Config\Services::curlrequest();

$response = $client->request('GET', $url, ['body' => 'html']);

echo $response->getHeader('Content-Type');

The short error message I get is

curl_setopt_array(): supplied argument is not a valid File-Handle resource

Again not sure what I'm doing wrong.

(This post was last modified: 05-28-2019, 08:20 AM by mightyted.)

Just reading this thread.


I didn't know that libcurl was a different entity. I guess this is the cause of my problem.


Theme © iAndrew 2016 - Forum software by © MyBB