Re: Reading input stream of incoming request
| From: | Reuben D. Budiardja | Date: | Thu, 06 Feb 2003 23:03:25 +0000 |
| Subject: | Re: Reading input stream of incoming request | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134688@lists.php.net to get a copy of this message | ||
On Thursday 06 February 2003 05:22 pm, Chris Shiflett wrote:
> --- "Reuben D. Budiardja" <reubendb@innovativethought.com>
>
> wrote:
> > I browse the archive and found the following code to
> > simulate a POST request using socket connection. This
> > will send a request to my own server (localhost). And
> > then, I also have the second code (included) for
> > /devel/php_post.php, which is the target for this
> > request.
>
> This sounds very screwed up, but maybe I am misinterpreting
> you. This is what this sounds like to me:
Hello,
Sorry for the confusion. Let me say I think I got things to work, somehow. But
just FYI and for the record, let me try to explain things again.
> 1. You have a script (send.php) that autmates a POST to
> another script (receive.php) that resides on the same host.
Correct.
> 2. You then include this same script (receive.php) in your
> sending script (send.php), thinking somehow that it has
> access to the data you just posted.
No. Apparently there was something wrong in my initial script send.php, that
makes it not running correctly. I re-wrote from scratch and got it to work.
And in receive.php, I just do phpinfo(). And no, I did not include
receive.php in send.php.
The original reason I asked about this is because I am building MIDLet
application with Java 2 Micro Edition (J2ME) Mobile Information Device
Profile (MIDP) specification for application in java enabled cell-phone.
This is the client side, and it needs to be able to POST data, and get the
reply from server, which running Apache + PHP ( + postgresql).
For some reason, from trying several examples I got, when the client POST the
data, the PHP script can't see it. Yes, I tried $_POST['varname'] (although I
have my register_global on) and phpinfo() to no avail.
From browsing several examples on how a Java servlet pages (JSP) handles this
kind of request, I know that the JSP needs to read the POST-ed input stream
byte by byte since that what client does (writing it as output stream).
So, I thought, a PHP page, somehow, needs to do this also, -- read the input
stream byte per byte--. And that's what I was trying to asked initially.
Now, I don't know how or why, but I just re-tried and re-code some of the
MIDLet apps example I got, and somehow, I manage to POST it in the "right
way" and the PHP can access the variable using $_POST['varname']. And I still
don't understand why it didn't work initially that prompt me to ask all kind
of confusing questions.
So, that's it. I guess I am just going in a circle and somehow got things to
work the second tine arround. Oh well, that the way some people learn :)
Anyway, thanks a lot for the respond and help.
-RDB