Jump to content

curl problems


Recommended Posts

I posted this on the fast moving php help forum, but I'm starting to think it might be an installation problem. I have the following code which works fine from the command line, but not from the browser:

 

<?php
$ch = curl_init() ;
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/") ;
curl_setopt($ch, CURLOPT_HEADER, 0) ;
curl_setopt($ch, CURLOPT_HEADER, true) ;
var_dump(curl_getinfo($ch)) ;
curl_exec($ch) ;
curl_close($ch) ;
?>

 

I'm thinking there might be a name server issue because I had to change my name server in /etc/resolv.conf recently because the ISP's name server is down. I'm using one from the opendns.org, which takes more time to respond than a local one would. Is there something I need to fix in my php config files? Or maybe it's apache related?

 

I get this when I run it from the command line:

array(20) {
  ["url"]=>
  string(22) "http://www.example.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(424)
  ["request_size"]=>
  int(72)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.055)
  ["namelookup_time"]=>
  float(0.003)
  ["connect_time"]=>
  float(0.003)
  ["pretransfer_time"]=>
  float(0.024)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(9911)
  ["speed_download"]=>
  float(180200)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(0)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.054)
  ["redirect_time"]=>
  float(0)
}

and this from the browser:

array(19) {
  ["url"]=>
  string(22) "http://www.example.com"
  ["http_code"]=>
  int(0)
  ["header_size"]=>
  int(0)
  ["request_size"]=>
  int(0)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0)
  ["namelookup_time"]=>
  float(0)
  ["connect_time"]=>
  float(0)
  ["pretransfer_time"]=>
  float(0)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(0)
  ["speed_download"]=>
  float(0)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(0)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0)
  ["redirect_time"]=>
  float(0)
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.