how to open an HTTP input stream in PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wabi
Forum Newbie
Posts: 1
Joined: Mon Nov 18, 2002 5:49 am

how to open an HTTP input stream in PHP?

Post by wabi »

Hi,

it would be fine if someone could give me an idea of how to get the data from an HTTP stream with PHP.

On client side there is a HTTP connection opened with the post method. Afterwards a output stream is defined in which data is transferred to the host. How can I get all the data sent via this stream?
This is how the client side could look like:

conn = (HttpConnection)Connector.open(url);
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestproperty("Content-Length", Integer.toString(request.length()));
out = conn.openOutputStream();
int requestLength = request.length();
for (int i=0; i<requestLength; ++i)
{
out.write(request.charAt(i));
}


How can I get the data transferred via the output stream of the String "request" in PHP?

I have browsed the PHP spec but I have not found how to solve this problem.

Thanks!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

depends on the content of request ;)
If it contains key/value-pairs they will be stored in the array $_POST (php version >= 4.1 and register globals of), files (mime-like encoded) in $_FILE.
If the data is not formatted at all (or unknown to php) you can access it via $GLOBALS['HTTP_RAW_POST_DATA']


http://www.php.net/manual/en/language.v ... predefined
http://www.php.net/manual/en/features.file-upload.php
Post Reply