php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70815 Linefeed not handled correctly in curl command output
Submitted: 2015-10-29 18:12 UTC Modified: 2015-11-08 04:22 UTC
From: abhatnagar at blackberry dot com Assigned:
Status: No Feedback Package: cURL related
PHP Version: 5.5Git-2015-10-29 (snap) OS: Ubuntu 3.16.0-51-lowlatency
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
12 + 1 = ?
Subscribe to this entry?

 
 [2015-10-29 18:12 UTC] abhatnagar at blackberry dot com
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-30 03:32 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-10-30 03:32 UTC] requinix@php.net
Do a View Source of the page.
 [2015-10-30 13:20 UTC] abhatnagar at blackberry dot com
Here is the relevant output of page source
<br><br>es-thr-hdp-02.dbplat.altus.bblabs.rim.net 10.236.133.158 7 55 0.00 d m es-thr-hdp-02 es-thr-hdp-01.dbplat.altus.bblabs.rim.net 10.236.133.157 4 56 0.00 d * es-thr-hdp-01 
<br>
</body>
</html>
 [2015-10-30 18:50 UTC] requinix@php.net
-Status: Not a bug +Status: Feedback
 [2015-10-30 18:50 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

Specifically, what's the rest of get_web_page's code?
 [2015-11-08 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 10 19:01:28 2024 UTC