note 50248 added to function.curl-setopt

From: Date: Wed, 23 Feb 2005 00:10:57 +0000
Subject: note 50248 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-85394@lists.php.net to get a copy of this message
If you want the same type of array with the header information as above, but dumping to a file instead, you can use this remove_headers function. It returns just the HTTP headers in a string, and copies the rest of the file to $out_file. function remove_headers ($in_file,$out_file) { $in = fopen ($in_file,'r+'); $out = fopen($out_file,'w+'); $headers = stream_get_line($in,4096,"\r\n\r\n"); fseek ($in,ftell($in)+4); while (!feof($in)){ fputs ($out,stream_get_line($in,4096,'')); } fclose ($in); fclose($out); return($headers); }//remove headers You can then pass the header string to the little parsing function written by Paul dot Ebermann at esperanto dot de to get the header array. This function is pretty quick for large files (100mb+) and seems a lot smarter and more resource friendly than putting 100mb into a string buffer. ---- Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50248 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50248&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50248&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50248&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50248&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50248&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50248&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85394) next »