php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77624 curl_getinfo() returns bad or empty entries for responses pushed via HTTP/2
Submitted: 2019-02-15 12:19 UTC Modified: 2021-10-19 15:09 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: nicolas dot grekas+php at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: cURL related
PHP Version: 7.3Git-2019-02-15 (Git) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nicolas dot grekas+php at gmail dot com
New email:
PHP Version: OS:

 

 [2019-02-15 12:19 UTC] nicolas dot grekas+php at gmail dot com
Description:
------------
When calling curl_getinfo() on a pushed curl handle, the resulting entries return bad timing info, bad URL, empty primary_ip, etc.

Test script:
---------------
$mh = curl_multi_init();

curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $onPush = function ($p, $c, $h) {
    return CURL_PUSH_OK;
});

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://http2-push.io');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_multi_add_handle($mh, $ch);

do {
    while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($mh, $active));

    while ($info = curl_multi_info_read($mh)) {
        print_r(curl_getinfo($info['handle']));
    }

    if (-1 === curl_multi_select($mh)) {
        usleep(1000);
    }
} while ($active);


Expected result:
----------------
entry "url" should be set to the pushed URL
entry "primary_ip" should be set to the pushing server IP
entry "starttransfer_time" should return plausible value
etc.

Actual result:
--------------
entry "url" is set to the URL of the parent response
entry "primary_ip" is empty
entry "starttransfer_time" is 0.0 or some impossible (more than 1M seconds)
etc.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-10-18 13:12 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2021-10-18 13:12 UTC] cmb@php.net
When testing against <https://http2.golang.org/serverpush>, I also
get fishy results.  There *might* be a bug in curl or maybe
nghttp2, which *might* have been fixed in more recent versions.
I'll need to check.
 [2021-10-19 15:09 UTC] cmb@php.net
-Status: Assigned +Status: Not a bug
 [2021-10-19 15:09 UTC] cmb@php.net
My previous comment was about a standard PHP-7.4 on Windows
(libcurl 7.70.0-4 and nghttp2 1.40.0).  Updating this to nghttp2
1.46.0 doesn't make a difference.  However, updating to libcurl
7.79.1 fixes the "url"s at least.  Since curl_getinfo()[1] is
basically a wrapper for curl_easy_getinfo(), and since the
easy_handle is apparantly correct (correct URLs), the issue is
likely with cURL.  Please consider to report this issue upstream.

[1] <https://github.com/php/php-src/blob/php-7.4.24/ext/curl/interface.c#L3279-L3544>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 15:01:30 2024 UTC