php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53842 the post data didn't show when using curl_getinfo($ch, CURLINFO_HEADER_OUT);
Submitted: 2011-01-26 04:55 UTC Modified: 2011-01-26 07:08 UTC
From: elementgi at qq dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.17 OS: WinXP
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: elementgi at qq dot com
New email:
PHP Version: OS:

 

 [2011-01-26 04:55 UTC] elementgi at qq dot com
Description:
------------
when i checking out the cURL header using CURLINFO_HEADER_OUT, the post data didn't show in the body.

the script:

    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, 'http://www.google.com.hk/webhp?hl=zh-CN&sourceid=cnhp' );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLINFO_HEADER_OUT, true );
    curl_setopt( $ch, CURLOPT_POST, true );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query(array('a'=>'1','b'=>'2')));
    $response = curl_exec( $ch );

    var_dump( curl_getinfo( $ch, CURLINFO_HEADER_OUT ) );
    
    curl_close( $ch );
    unset( $ch );



Test script:
---------------
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, 'http://www.google.com.hk/webhp?hl=zh-CN&sourceid=cnhp' );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLINFO_HEADER_OUT, true );
    curl_setopt( $ch, CURLOPT_POST, true );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query(array('a'=>'1','b'=>'2')));
    $response = curl_exec( $ch );

    var_dump( curl_getinfo( $ch, CURLINFO_HEADER_OUT ) );
    
    curl_close( $ch );
    unset( $ch );

the result:

POST /webhp?hl=zh-CN&sourceid=cnhp HTTP/1.1
Host: www.google.com.hk
Accept: */*
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

the expected result:

POST /webhp?hl=zh-CN&sourceid=cnhp HTTP/1.1
Host: www.google.com.hk
Accept: */*
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

a=1&b=2    // <- missing this

Expected result:
----------------
POST /webhp?hl=zh-CN&sourceid=cnhp HTTP/1.1
Host: www.google.com.hk
Accept: */*
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

a=1&b=2

Actual result:
--------------
POST /webhp?hl=zh-CN&sourceid=cnhp HTTP/1.1
Host: www.google.com.hk
Accept: */*
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-26 07:08 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2011-01-26 07:08 UTC] aharvey@php.net
As the name suggests, CURLINFO_HEADER_OUT only tracks the request
headers, not the entire request body.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC