473,546 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending http requests with curl but closing before reading the response

Is it possible to send http requests with curl but not have curl wait
for the response?

The reason I ask is because I'd like to code a web app that can sorta
start time consuming processes without the user having to wait. I'm
doing this (with fsockopen) by sending an http request to a page that
does the time consuming stuff and then immediatly closing, without
having read any of the response. This way, I don't have to wait for
the response.

Is it possible to do the same thing with curl? Sending just HEAD
requests doesn't work since it'd seem that the response (which I don't
yet know how to disable, if possible) is only sent at the end of the
pages execution. This might be a mod_gzip issue, but I'd rather use
fsockopen then disable mod_gzip.

Any ideas?

Jul 27 '06 #1
4 12130
yawnmoth wrote:
Is it possible to send http requests with curl but not have curl wait
for the response?

The reason I ask is because I'd like to code a web app that can sorta
start time consuming processes without the user having to wait. I'm
doing this (with fsockopen) by sending an http request to a page that
does the time consuming stuff and then immediatly closing, without
having read any of the response. This way, I don't have to wait for
the response.

Is it possible to do the same thing with curl? Sending just HEAD
requests doesn't work since it'd seem that the response (which I don't
yet know how to disable, if possible) is only sent at the end of the
pages execution. This might be a mod_gzip issue, but I'd rather use
fsockopen then disable mod_gzip.

Any ideas?
Hi yawnmoth,

I think the best approach is to leave CURL and normal tcp/ip interaction
intact. This means: wait for the response.
In that way you actually know that system that performs the calculations is
up and running.

You can however make the heavycalc-script return its response immediately,
and THEN do the calculations.

Maybe someone has a more ellegant solution out there, but this could work:
1) use ob_start() at top of script
2) send a header telling the browser/CURL to go away:
header("Locatio n: bla.html");
where bla.html is a small useless file. Maybe containing only 'doing calc'
or something.
3) flush it to the browser/CURL: ob_flush();

I expect as far as CULR is concerned, the respons ended, but you first
script can now continue doing your calculations.

Do not produce any output from here. Not sure where it goes if you do. :-)

Not tested. I think I solved that problem once like this. But it is quickly
tested by you. Please let us know if it works.

just my 2 cent

Regards,
Erwin Moller
Jul 27 '06 #2

Erwin Moller wrote:
yawnmoth wrote:

<snip>

Hi yawnmoth,

I think the best approach is to leave CURL and normal tcp/ip interaction
intact. This means: wait for the response.
In that way you actually know that system that performs the calculations is
up and running.

You can however make the heavycalc-script return its response immediately,
and THEN do the calculations.

Maybe someone has a more ellegant solution out there, but this could work:
1) use ob_start() at top of script
2) send a header telling the browser/CURL to go away:
header("Locatio n: bla.html");
where bla.html is a small useless file. Maybe containing only 'doing calc'
or something.
3) flush it to the browser/CURL: ob_flush();

I expect as far as CULR is concerned, the respons ended, but you first
script can now continue doing your calculations.

Do not produce any output from here. Not sure where it goes if you do. :-)

Not tested. I think I solved that problem once like this. But it is quickly
tested by you. Please let us know if it works.

just my 2 cent
That's what register_shutdo wn_function used to do in PHP 4.0.6 and
earlier under Apache. Unforutnately, last time I tried it, it didn't
work with mod_gzip (I had to disable it for that to work).

Jul 27 '06 #3
yawnmoth wrote:
>
Erwin Moller wrote:
>yawnmoth wrote:

<snip>

Hi yawnmoth,

I think the best approach is to leave CURL and normal tcp/ip interaction
intact. This means: wait for the response.
In that way you actually know that system that performs the calculations
is up and running.

You can however make the heavycalc-script return its response
immediately, and THEN do the calculations.

Maybe someone has a more ellegant solution out there, but this could
work: 1) use ob_start() at top of script
2) send a header telling the browser/CURL to go away:
header("Locati on: bla.html");
where bla.html is a small useless file. Maybe containing only 'doing
calc' or something.
3) flush it to the browser/CURL: ob_flush();

I expect as far as CULR is concerned, the respons ended, but you first
script can now continue doing your calculations.

Do not produce any output from here. Not sure where it goes if you do.
:-)

Not tested. I think I solved that problem once like this. But it is
quickly tested by you. Please let us know if it works.

just my 2 cent
That's what register_shutdo wn_function used to do in PHP 4.0.6 and
earlier under Apache. Unforutnately, last time I tried it, it didn't
work with mod_gzip (I had to disable it for that to work).
well, did you try it?
Jul 27 '06 #4
On 27 Jul 2006 00:14:10 -0700, "yawnmoth" <te*******@yaho o.comwrote:
>Is it possible to send http requests with curl but not have curl wait
for the response?

The reason I ask is because I'd like to code a web app that can sorta
start time consuming processes without the user having to wait. I'm
doing this (with fsockopen) by sending an http request to a page that
does the time consuming stuff and then immediatly closing, without
having read any of the response. This way, I don't have to wait for
the response.

Is it possible to do the same thing with curl? Sending just HEAD
requests doesn't work since it'd seem that the response (which I don't
yet know how to disable, if possible) is only sent at the end of the
pages execution. This might be a mod_gzip issue, but I'd rather use
fsockopen then disable mod_gzip.
I suppose you could use CURLOPT_TIMEOUT set to a short timeout?

I'm not sure what the scope of CURLOPT_TIMEOUT is - if it's for the transfer
only, and CURLOPT_CONNECT ION_TIMEOUT is specifically for the handshaking, then
it ought to fit your purpose.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 27 '06 #5

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

Similar topics

17
3192
by: Stefan Richter | last post by:
Hi, I would like to conect to a server by a SSL Conection, to send an SMS. The company that offers the SMS service provided some Code for a http connection, but not for a https connection. Here is the code to send an SMS by http, which works great. Can you help / or do you know a good tutorial / website for php and ssl ??? thanx,
1
2688
by: Desmond Rivet | last post by:
Hi all, I will do an experiment on this soon, but if anyone knows off the top of their head... Let's say you have a servlet that processes a POST request. A HTTP client sends a POST request to this servlet and attaches a relatively long body to the request, say 4MB. The type of the body doesn't matter, let's say it's just text/plain.
1
2223
by: Dhwanil Shah | last post by:
Hi, We have an aspx page designed in VS.NET 2003. Our requirement is that a client (another application), sends HEAD requests to our application with Basic Auth header. Based on security criteria, we need to "tell" the other application whether the user is allowed to use that page or not. Another criteria is that if a specific user comes to...
2
2425
by: jdonnell | last post by:
How can I send an http request with php that is similar to the following? Notice the raw (unnamed) post data. HTTP/1.1 200 OK Date: Mon, 12 Aug 2002 01:31:10 GMT Status: 200 OK Connection: Close Content-Length: 510 Content-Type: text/xml; charset=UTF-8
3
2135
by: webEater | last post by:
Hey, I am writing a file that reads in an external file in the web and prints it out including the response header of the http protocol. I do this to enable cross domain XMLHttpRequests. I implemented it via fsockopen, like this: <? $url = $_REQUEST; // take the param as $uri //... more ...
9
2013
by: devranger | last post by:
I am using the below CURL Function and can not figure out why it is not retruning the results from the post. Can anyone take a look and tell me what I may be doing wrong? I am just not seeing it. As you can see at the bottom of the script if (strstr($Line, 'HOUSTON YAMAHA MOTORSPORTS')) then it is reading the correct page, otherwise if...
0
1513
by: existatus | last post by:
In a form there are entries like this: <input type="text" name="first_name" size="24" /> <input type="text" name="last_name" size="24" /> <input type="hidden" name="must_have" value="12345" /> <input type="hidden" name="recipient" value="myemail@comcast.net" /> <input type="hidden" name="redirect" value="http://mywebsite.com" /> <input...
3
4016
by: empiresolutions | last post by:
I'm new to sending, receiving, and reading XML. I'm trying to send and receive XML data via cURL. I am using curl because it was so easy with just arrays. I am using the following code to generate the XML and the PHP script that is presently not working. It would be great if some great code god can explain whats wrong to me. build_xml.php ...
9
5574
by: lilbit02 | last post by:
Can someone please help me with this. I have gone to forum after forum and read books and just have no idea how to do this. I need to send a server response in PHP. I'm attempting to do with CURL. I might be making this harder than need be because I over think things and then I get myself all confused. This is the scenario...I have vendors...
0
7507
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7698
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7794
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1922
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.