473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Responding To HTTP Post

I am trying to figure out how to respond to an HTTP post in php script.
Can anyone help?

Nov 27 '05 #1
10 4586
Only you can answer how you plan to code the response, but if you do
get http post you can access it like:

$var1 = $_POST['var1'];

or to start off use:

print_r ($_POST); //which will show all the data posted to the script.

Nov 27 '05 #2
My question deals with establishing a connection. It appears that
establishing a new connection using fsockopen() would not connect me to
the originator's session and I don't know how to re-use the existing
connection.

Nov 27 '05 #3
My question deals with establishing a connection. It appears that
establishing a new connection using fsockopen() would not connect me to
the originator's session and I don't know how to re-use the existing
connection.

Nov 27 '05 #4
OK, use http://php.net/curl

Nov 27 '05 #5
I was not able to find the answer to my question in the CURL
documentation. I understand that it may not be possible to do this
using php.

My script would get a request via POST from a client. The client would
wait for response. In order for me to respond, I need to get a handle
to the initial connection. This may not be possible. I think that this
type of situations are usually handled via a coordinating daemon.

Nov 27 '05 #6
>I was not able to find the answer to my question in the CURL
documentation. I understand that it may not be possible to do this
using php.

My script would get a request via POST from a client. The client would
wait for response. In order for me to respond, I need to get a handle
to the initial connection.
If your page is running under PHP, you already have a connection.
Output something (say, with echo or header() or something).
This may not be possible. I think that this
type of situations are usually handled via a coordinating daemon.


If you are making an outgoing connection to something (with, say,
fopen on a remote URL) and want to copy the response IT sends to
the request you got, look at fpassthru().

Otherwise, I don't understand your problem.

Gordon L. Burditt
Nov 27 '05 #7
My question is not well stated. Let me try again.

I am working on a php script that will receive database requests from
remote URL's. The script's job is to execute the request and send the
results back to the requester.

The requester does the following:

1. Open a connection using fsockopen().
2. Post headers and request using fputs()
3. Read response using fgets()

This works fine. I am using a class that does that in other
applications communicating with applications that successfully send the
responses back. I am trying to write a script that also sends responses
back and that is where I am running into difficulties

The problem script obtains the request from $_POST. That also works.
The question is how do I send the response back to requester so that it
can read it using fgets(). Or, more specifically, how do I establish a
connection back to the requester so that I can send the response.

If I use fsockopen() to establish a connection to the requesting URL,
it appears that it would not be communicating with the same session. I
also don't see a way to get a handle to the existing connection that
was created by the requester.

Nov 28 '05 #8
>My question is not well stated. Let me try again.

I am working on a php script that will receive database requests from
remote URL's. The script's job is to execute the request and send the
results back to the requester.

The requester does the following:

1. Open a connection using fsockopen().
2. Post headers and request using fputs()
3. Read response using fgets()
Forget these details. Pretend the situation is: Someone typed the
URL into a browser or clicked on a link. Then do what is appropriate:
output something. Ok, you're outputting xml instead of html. Big
deal. Text is text. When you get a request, it's difficult to
tell that it's *NOT* someone with a browser, and you shouldn't try
to distinguish the difference anyway.
This works fine. I am using a class that does that in other
applications communicating with applications that successfully send the
responses back. I am trying to write a script that also sends responses
back and that is where I am running into difficulties

The problem script obtains the request from $_POST. That also works.
The question is how do I send the response back to requester so that it
can read it using fgets().
Don't even think about trying to establish a connection, the other
end already did it. OUTPUT SOMETHING!! echo. print. printf.
fpassthru. (Maybe you want a header("Content-type: text/xml")
first).

echo "<xml>response</xml>\n";

Note the complete absence of any reference to functions with the
substring "open" or "sock" and the complete absence of handles.
Or, more specifically, how do I establish a
connection back to the requester so that I can send the response.
When you receive a telephone call, answer it, and the caller asks
a question, do you need to call him back to send answer? No, you
just *TALK*. It doesn't matter whether the caller is using a VOIP
switch or an old mechanical switchboard and asked the operator to
make the call for him. It doesn't matter whether the call goes
via a satellite. You just talk.
If I use fsockopen() to establish a connection to the requesting URL,
Do not establish a connection. You've got one established by the
other end. USE IT!
it appears that it would not be communicating with the same session. I
also don't see a way to get a handle to the existing connection that
was created by the requester.


You don't need a handle. OUTPUT SOMETHING!!!
Gordon L. Burditt
Nov 28 '05 #9
Got it! Thanks. Now I just need to find an optimal way to deal with
chunked encoding.

Nov 28 '05 #10
Hello,

on 11/27/2005 03:59 PM Zack said the following:
My question deals with establishing a connection. It appears that
establishing a new connection using fsockopen() would not connect me to
the originator's session and I don't know how to re-use the existing
connection.


You may want to try this HTTP Client class that can submit post
requests, collect and send back cookies (of your sessions) and most of
other operations to make it act like a real browser:

http://www.phpclasses.org/httpclient
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Nov 28 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: long5120 | last post by:
I am trying to use webpage with javascript to check if a web server is responding. I was thinking of using 2 frames. Frame1 will have the site, and the Frame2 will be a status bar (not really...
3
by: TM360 | last post by:
I realize this may not be the right group to post this, but I'm not having much success elsewhere so I thought I'd give it a try... In our application we have a link that opens a new window...
2
by: Rythm Music | last post by:
Sometimes my application stops responding. However I do not see an error and not sure what to do. Any help will be great. *** Sent via Developersdex http://www.developersdex.com ***...
0
by: dotnet user | last post by:
I have a asp.net webpage which has aroud 20 steps as hyperlink. when start button is clicked, then step1 starts which does some operation in db and returns some value, based on that value i post...
3
by: scs | last post by:
Has anyone experienced the situation where control buttons stop responding to click event handlers? I have a form with 8 buttons that were responding to their click events but are not anymore. Does...
2
by: Mahmoud Metwally | last post by:
Dear Sir, Which VB6 functions can I use to detect some program is not responding to make it automatically restarted. So, how to detect that this is NOT RESPONDING program, and How To Restart it....
6
by: sprayer | last post by:
I have a UI thread not responding also. I have an Async operation that I am processing a long running SQL script in ADO.Net. I am executing the Command asynchronous and hooking the...
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
7
by: MrDeej | last post by:
Hello I have noticed that access usually "stops responding" when i activiate large SQL operations. This is a problem in the case that i want i. e. a postcounter which tells the user how many post...
18
by: rdahlstrom | last post by:
Does anyone know how to determine the window status (Running or Not Responding)? I've tried various methods with no success... This would be on a variety of Windows systems, but all at least XP,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.