Page 1 of 1

how to open an HTTP input stream in PHP?

Posted: Mon Nov 18, 2002 5:49 am
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!

Posted: Mon Nov 18, 2002 8:10 am
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