note 89669 modified in function.curl-setopt by danbrown

From: Date: Wed, 18 Mar 2009 16:16:02 +0000
Subject: note 89669 modified in function.curl-setopt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152101@lists.php.net to get a copy of this message
I wanted to create a script that acted as a bridge between an external server and an internal server, wherein the internal server was not connected to the internet, but had information required by the users connecting to the external server. I hatched the idea to use curl to connect from the external server to the internal server (using request variables to send queries) and return everything (data and headers) returned by the file server. After being driven mad by segmentation faults and crashes because the curl_exec didn't like me having the CURLOPT_HEADERFUNCTION's function directly dumping the header: <?php function Duplicate_Header($curl, $header) { header($header); return strlen($header); } ?> ... I tried (on a whim) duplicating and trimming the header and passing the duplicate to the header function... <?php function Duplicate_Header($curl, $header) { $duplicate = trim($header); header($duplicate); return strlen($header); } ?> Which worked just fine. I don't know if this is just some quirk of PHP4 or my lack of understanding of how the curl and header function works. --was-- I wanted to create a script that acted as a bridge between an external server and an internal server, wherein the internal server was not connected to the internet, but had information required by the users connecting to the external server. I hatched the idea to use curl to connect from the external server to the internal server (using request variables to send queries) and return everything (data and headers) returned by the file server. After being driven mad by segmentation faults and crashes because the curl_exec didn't like me having the CURLOPT_HEADERFUNCTION's function directly dumping the header: function Duplicate_Header($curl, $header) { header($header); return strlen($header); } ... I tried (on a whim) duplicating and trimming the header and passing the duplicate to the header function... function Duplicate_Header($curl, $header) { $duplicate = trim($header); header($duplicate); return strlen($header); } Which worked just fine. I don't know if this is just some quirk of PHP4 or my lack of understanding of how the curl and header function works. http://php.net/manual/en/function.curl-setopt.php

« previous php.notes (#152101) next »