|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27628 stream http context
Submitted: 2004-03-17 16:25 UTC Modified: 2004-03-17 19:31 UTC
From: php at virtualmonet dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5CVS-2004-03-17 (dev) OS: linux
Private report: No CVE-ID: None
 [2004-03-17 16:25 UTC] php at virtualmonet dot com

It seems that the Context option 'content' of HTTP wrapper for stream, does not pass the value to the server.

Reproduce code:
// === client side php code === 

$opts = array('http'=>array('method'=> "POST",
                            'content' => 'foo=bar'));

$context = stream_context_create($opts);

echo file_get_contents ($url, false, $context);

// === server side php code ===
print $_POST['foo'];

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-17 19:31 UTC]
Because that's not a complete POST request.

You also need to specify the correct content-type (and preferrably content-length) in the header. (You can use the header context option for this)  Refer to example2 on if you need an example of what the headers should look like.

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 08:01:25 2019 UTC