Bug #70815 [Nab]: Linefeed not handled correctly in curl command output
Edit report at https://bugs.php.net/bug.php?id=70815&edit=1
ID: 70815
User updated by: abhatnagar at blackberry dot com
Reported by: abhatnagar at blackberry dot com
Summary: Linefeed not handled correctly in curl command
output
Status: Not a bug
Type: Bug
Package: cURL related
Operating System: Ubuntu 3.16.0-51-lowlatency
PHP Version: 5.5Git-2015-10-29 (snap)
Block user comment: N
Private report: N
New Comment:
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>
Previous Comments:
------------------------------------------------------------------------
[2015-10-30 03:32:05] requinix@php.net
Do a View Source of the page.
------------------------------------------------------------------------
[2015-10-29 18:12:03] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70815&edit=1
Thread (5 messages)