Re: libcurl(?) bug

From: Date: Tue, 09 Feb 2021 12:30:22 +0000
Subject: Re: libcurl(?) bug
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-327481@lists.php.net to get a copy of this message
On 09.02.2021 at 13:17, Tamas Papp wrote: > I might found a bug, but I'm unsure and I'm unsure if it's libcurl or a > php issue. > > > There is this code (got from a dev, I am a sysadmin): > > <?php >   ini_set('display_errors', 1); >   error_reporting(E_ALL); > >   $ch = curl_init(); >   $url = 'https://google.com'; >   curl_setopt($ch, CURLOPT_URL, $url); >   curl_setopt($ch, CURLOPT_HEADER, false); >   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); >   curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 0); >   curl_setopt($ch, CURLOPT_TIMEOUT, 30); >   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); >   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); >   // ORIGINAL: >   //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: xml/, text/, > /\r\n")); > >   // OK: >   //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: /\r")); > >   // NOK: >   curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: /\r\n")); > >   $response = curl_exec($ch); >   if(curl_exec($ch) === false) $response .= curl_error($ch); >   curl_close($ch); > >   print_r($response); > ?> > > There is an extra HTTP header is like this and it works: > >   curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: /\r")); > > > It does not work if it looks like this: > >   curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: /\r*\n*")); > > > Or it works if the $url is not *https*, but http. > > > The original code worked on Debian 9 and Ubuntu 18.04 and does not work > on Debian 10 and Ubuntu 20.04 and no matters if PHP comes from Sury's > PPA or from the original distribution. > > That's why libcurl is suspicious to me. > > > Do you have any thoughts on this? I don't think that CURLOPT_HTTPHEADERs are supposed to have a trailing CRLF. Christoph

« previous php.general (#327481) next »