#30475 [Opn->Csd]: Curl curl_getinfo()

From: Date: Mon, 18 Oct 2004 22:43:41 +0000
Subject: #30475 [Opn->Csd]: Curl curl_getinfo()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-67751@lists.php.net to get a copy of this message
ID: 30475 Updated by: iliaa@php.net Reported By: mikeb at xamo dot com -Status: Open +Status: Closed Bug Type: cURL related Operating System: FreeBSD 4.8 PHP Version: 5.0.2 New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2004-10-18 23:02:15] mikeb at xamo dot com Description: ------------ When requesting the CURLINFO_CONTENT_TYPE using curl_getinfo(), if there is an error (such as connection error) or missing header for any reason, running the function using specifically curl_getinfo($fd,CURLINFO_CONTENT_TYPE) will cause a PHP core dump. The problem seems to be that the function does not check for the instance of the Content-Type: header before it tries to parse it. Temporary workaround is simply not using the function, and parsing for the data yourself. Reproduce code: --------------- <? $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,"http://sell.yahoo.com/"); curl_setopt($ch,CURLOPT_HEADER,1); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $contents=curl_exec($ch); // the following line will cause a core dump // as sell.yahoo.com does not return an appropriate Content-Type header. Also happens on connect errors. $content_type=curl_getinfo($ch,CURLINFO_CONTENT_TYPE); curl_close($ch); ?> Expected result: ---------------- Should return content-type in the HTTP Header (if it exists, or false/empty string if it doesnt exist) Actual result: -------------- PHP Core Dump. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30475&edit=1

« previous php.bugs (#67751) next »