Bug #70815 [NEW]: Linefeed not handled correctly in curl command output

From: Date: Thu, 29 Oct 2015 18:12:06 +0000
Subject: Bug #70815 [NEW]: Linefeed not handled correctly in curl command output
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196887@lists.php.net to get a copy of this message
From:             abhatnagar at blackberry dot com
Operating system: Ubuntu 3.16.0-51-lowlatency
PHP version:      5.5Git-2015-10-29 (snap)
Package:          cURL related
Bug Type:         Bug
Bug description:Linefeed not handled correctly in curl command output

Description:
------------
Command Line curl output with linefeeds. Displayed correctly in
terminal.
curl -vvv 'localhost:9200/_cat/nodes/?v'
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
> GET /_cat/nodes/?v HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:9200
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=UTF-8
< Content-Length: 357
<
host                                      ip             heap.percent
ram.percent load node.role master name
es-thr-hdp-02.dbplat.altus.bblabs.rim.net 10.236.133.15            3    
     55 0.01 d         m      es-thr-hdp-02
es-thr-hdp-01.dbplat.altus.bblabs.rim.net 10.236.133.17            9    
     56 0.00 d         *      es-thr-hdp-01

Same output in php displayed out put in browser without linefeed as a
single line:

HTTP/1.1 200 OK Content-Type: text/plain; charset=UTF-8 Content-Length:
357 host ip heap.percent ram.percent load node.role master name
es-thr-hdp-02.dbplat.altus.bblabs.rim.net 10.236.133.15 3 55 0.00 d m
es-thr-hdp-02 es-thr-hdp-01.dbplat.altus.bblabs.rim.net 10.236.133.17 9
56 0.00 d * es-thr-hdp-01 


Test script:
---------------
function get_web_page( $url )
{
    $options = array(
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => true,    // don't return headers
        CURLOPT_VERBOSE        => true,    //
        CURLOPT_CRLF           => true,    //
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_USERAGENT      => "spider", // who am i
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 5,      // timeout on connect
        CURLOPT_TIMEOUT        => 5,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
        CURLOPT_HTTPHEADER      => array('Content-Type: text/plain'),   
   //
    );
....
   $url = "http://$master_nodes:9200/_cat/nodes?v";
   echo "<br>";
   $curl_response = get_web_page( $url );
   echo $curl_response['content'];
   echo "<br>";




Expected result:
----------------
Output should be on different lines: as below


HTTP/1.1 200 OK 
Content-Type: text/plain; charset=UTF-8 
Content-Length: 357

host ip heap.percent ram.percent load node.role master name 
es-thr-hdp-02.dbplat.altus.bblabs.rim.net 10.236.133.158 3 55 0.00 d m
es-thr-hdp-02 
es-thr-hdp-01.dbplat.altus.bblabs.rim.net 10.236.133.157 9 56 0.00 d *
es-thr-hdp-01 

Actual result:
--------------
HTTP/1.1 200 OK Content-Type: text/plain; charset=UTF-8 Content-Length:
357 host ip heap.percent ram.percent load node.role master name
es-thr-hdp-02.dbplat.altus.bblabs.rim.net 10.236.133.158 3 55 0.00 d m
es-thr-hdp-02 es-thr-hdp-01.dbplat.altus.bblabs.rim.net 10.236.133.157 9
56 0.00 d * es-thr-hdp-01 

Note: Content Array returned has only 1 element for single line.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70815&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70815&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70815&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70815&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70815&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70815&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70815&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70815&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70815&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70815&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70815&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70815&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70815&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70815&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70815&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70815&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70815&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70815&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70815&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70815&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70815&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#196887) next »