cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Connections ??

From: David Colter <dolan2go_at_yahoo.com>
Date: Fri, 8 Feb 2008 21:19:08 -0500

Please advise on the best practice for implementing curl/php when
using several different page requests.

The host is always the same, the script is capturing and managing
cookie management and I am just changing the curlopt's that are
different from the last setting. I'm only using 'curl_init ()' once
for 1 handle and using cur_exec for each new page requested. In the
verbose output it is warning 'closing connection 4' and then at the
end states 'closing connection 0' thru 'closing connection 4'.

Is this normal for this type of process? Any suggestions would be
greaty appreciated. Below is an example of the curl portion of the 1st
page request I'm using. BTW, everything is working splendidly
otherwise. Many thanks for the thoroughness of curl.

$ch1 = curl_init();

curl_setopt($ch1, CURLOPT_MAXCONNECTS, 6);
curl_setopt($ch1, CURLOPT_USERAGENT, $WEBBOT_NAME);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE); // Needed for
https: & no certificate
curl_setopt($ch1, CURLOPT_URL, $target); // Define
target site
curl_setopt($ch1, CURLOPT_REFERER, $ref); // Define
refering page
curl_setopt($ch1, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch1, CURLOPT_STDERR, $fp);
curl_setopt($ch1, CURLOPT_NOPROGRESS, FALSE);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header_array); // Send
Accept: Header values
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, TRUE); // Return
page in String
curl_setopt($ch1, CURLOPT_COOKIESESSION, TRUE);
# curl_setopt($ch1, CURLOPT_COOKIEJAR, $cookie_file); // Where to
WRITE cookies
# curl_setopt($ch1, CURLOPT_COOKIEFILE, $cookie_file); // Where to
READ cookies FROM
curl_setopt($ch1, CURLOPT_HEADER, TRUE);
curl_setopt($ch1, CURLOPT_NOBODY, TRUE);
curl_setopt($ch1, CURLOPT_POST, FALSE); // Use GET
Method
curl_setopt($ch1, CURLOPT_FRESH_CONNECT, TRUE); // Force New
Cache connection
# curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, TRUE);

$page1_array_hdr['FILE'] = curl_exec($ch1);
$page1_array_hdr['ERROR'] = curl_error($ch1);
$page1_array_hdr['STATUS'] = curl_getinfo($ch1);

Thanks,
David Colter
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-02-09