Sending POST Requests without waiting for response?

php send post request without waiting for response
python http request without waiting for response
python-requests wait for response
python requests post json
java send http request without waiting for response
curl without waiting
async post request python
resttemplate not wait for response

I am writing a simple REST service, which responds to requests from clients. All in PHP.

My concern is, that when my server responds to a request, it could end up tying up resources if the client side is too slow in sending back "ok" response.

How do I send a POST request via lib_curl setting it to not wait for any responses, but rather quit immidiately after the POST data have been sent?

Is this even possible? Thank you !

You cannot just send data without receiving an answer with HTTP. HTTP always goes request -> response. Even if the response is just very short (like a simple 200 with no text), there needs to be a response. And every HTTP socket will wait for that response.

If you don't care about the response, you could add a process to the server that makes your requests, and you just push your request data to it (like a service that is running in the background, checking a request database, and always starting the request whenever a new entry was added). That way you would make the request asynchronously and could quit as soon as you added that request to the stack.

Also as meouw said, the client is not part of any communication you are doing with php. Php is a server-side language, so when the client requests a webpage (the php file), the server executes that file (and does all requests the php file states) and then returns the result to the client.

Post parallel cURL requests in the background without waiting for a , PerformInBackground" ; # ) that sends out a cURL request without waiting for a response and lets the FM script move forward to the next script  Subject: Re: Sending HTTP requests without waiting for response. 03/04/03 08:09 PM Sathya, I had this same need come up a few days ago. Here's how I solved the problem: Script #1 needs to send an HTTP request without waiting for a response. Instead of passing the call to libwww (or whatever HTTP method you're

This solutions is for software minimal recevied package to continue script. If you want don't care about respond and have access to exec than use exec and call script in background. First Recevier File:


ignore_user_abort(true); //continue script if connetions become close by webbrowser(client) within working script

ob_end_clean(); // this 4 lines just extra sending to web about close connect it just in case
header("Connection: close\r\n"); //send to website close connect 
header("Content-Encoding: none\r\n"); 
header("Content-Length: 1"); //

fastcgi_finish_request(); //close nginx,apache connect to php-fpm (php working but nginx or apache stop communication with php)
//continue scripting 
//check test with your mongo or mysql to sure php still keep connection with db

FRONTGROUND by PHP request to HTTP: this solution is better than background and you need wait only 1ms


 curl_setopt($curl, CURLOPT_TIMEOUT_MS, 1); //HERE MAGIC (We wait only 1ms on connection) Script waiting but (processing of send package to $curl is continue up to successful) so after 1ms we continue scripting and in background php continue already package to destiny. This is like apple on tree, we cut and go, but apple still fallow to destiny but we don't care what happened when fall down :) 
 curl_setopt($curl, CURLOPT_NOSIGNAL, 1); // i'dont know just it works together read manual ;)

--------- Check next answer to complete solution ------------

BACKGROUND By Server Request to HTTP: This will execute $cmd in the background (no cmd window) without PHP waiting for it to finish, on both Windows and Unix. @source

function execInBackground($cmd) {
    if (substr(php_uname(), 0, 7) == "Windows"){
        pclose(popen("start /B ". $cmd, "r")); 
    else {
        exec($cmd . " > /dev/null &");  

How to make an HTTP request without getting back an HTTP , This way you'll be getting control back to your app as soon as request is sent, without spending single millisencond waiting for answer. Additionally, I'd invest  OP says "I just want to post the information without waiting for a response." The problem here is that HttpClient.PostAsync will automatically read the response stream. If one wishes to just send data and not bother reading the response, there is no actual need to have any operation, async or not, to read the request stream (ie wait for the server to respond).

If you really don't care about the response you're probably best off exec-ing a wget command. This is mentioned in passing in some of the other answers, but here's a super easy function for sending a _POST package via this approach (which is asynchronous and takes 1-2ms):

function wget_request($url, $post_array, $check_ssl=true) {

  $cmd = "curl -X POST -H 'Content-Type: application/json'";
  $cmd.= " -d '" . json_encode($post_array) . "' '" . $url . "'";

  if (!$check_ssl){
    $cmd.= "'  --insecure"; // this can speed things up, though it's not secure
  $cmd .= " > /dev/null 2>&1 &"; //just dismiss the response

  exec($cmd, $output, $exit);
  return $exit == 0;

Credits: Function was adapted from

Python Requests post Method, The post() method sends a POST request to the specified url. indicating how many seconds to wait for the client to make a connection and/or send a response. Some functions allow you to achieve something very similar to this HTTP-ping, by not waiting for a response. Take note that the process of pinging an url, is a two step process: Resolve the DNS; Making the request

libcurl has no asynchronous interface. You can do that yourself either by using threads or by using the non-blocking "multi interface" that libcurl offers. Read up on the multi interface here:

PHP example of multi interface is here:

Python and fast HTTP clients, This library allows sending requests in series but without waiting for the ClientSession() as session: async with session.get(url) as response:  Can you quote the RFC (or other source) justifying "You cannot just send data without receiving an answer with HTTP"?. From a TCP standpoint, it is possible to send multiple POST without waiting for the response, so that must be explicitly forbiden somewhere in an HTTP specification. – fgrieu Oct 22 '18 at 9:40

I have never tried this, but setting the CURLOPT_TIMEOUT to a very low value might do the trick. Try 0 or 0.1.

However, I don't know how cURL and the client will behave with this, whether the connection will be actively cancelled when the connection is already established, and the timeout is reached. You would have to try out. If you're calling PHP scripts, maybe ignore_user_abort() can make sure your scripts run through either way.

chttp - Rust, By default, sending a request will wait for the response, up until the response Sending a POST request is also easy, and takes an additional argument for the You can start sending requests without any configuration by using the global  from the above code you can send async requests without getting response. Specify timeout according to your need. if not it will not time out. read Quickstart - Requests 2.13.0 documentation for more info on timeouts. 5.8k views · View 3 Upvoters

Fire and Forget HTTP Requests in PHP ∙ Chris White, This client is what sends your Laravel application logs to Loglia. It would be ideal if we could fire off the HTTP request and continue processing the script without waiting They do still wait for a response to be returned before continuing 443 : 80; $contentLength = strlen($postData); $request = "POST  send packets from one machine to another ; without the first machine to wait for any response; and the interval between the packets to be 1us; It will be preferable to do it with the ping command and the options that it provides (if they are sufficient). I have administrator privileges.

Make a synchronous request to the server, and wait for a response , Use a POST method to make a synchronous request to the server. No other HTTP methods are necessary to retrieve the response from the server. The following setRequestHeader("content-type", "application/json"); xhr.send(data);​  Send one meeting request without response required in Outlook. It is easy to send a meeting request without response required in Microsoft Outlook. Step 1: Create a new meeting invitation: In Outlook 2010 and 2013, shift to the Calendar view, and click the New Meeting button on the Home tab. In Outlook 2007, please click the File > New

Server Asynchronous Response Processing, For a typical HTTP server, when a request comes in, one thread is dedicated to or POST request and just block indefinitely until the server was ready to send by a background thread that would send a response back to all waiting clients  Bug report Describe the bug next api route logs API resolved without sending a response for /graphql, this may result in stalled requests. even though it sends a response; To Reproduce Set up a route like: // /api/graphql.ts import { cre

  • It's not the client that sends the 200 OK response, but the server. The client makes a request and the server responds, the server doesn't care what is going on with the client (by definition in REST, it is stateless). What are you trying to, could you elaborate?
  • That's what I needed to know :) Thank you
  • @Gotys sidenote, if you want to just send a "request" without waiting for a response, look in to the UDP protocol
  • There is the fire and forget "pattern". An asyc request will fire the request. Once executed you can do something else without waiting. In the scenario where you have a reliable network connection UDP is an option but TCP is more reliable in that you know the packets will make it. However, without checking the response you won't know what happened.
  • Can you quote the RFC (or other source) justifying "You cannot just send data without receiving an answer with HTTP" ?. From a TCP standpoint, it is possible to send multiple POST without waiting for the response, so that must be explicitly forbiden somewhere in an HTTP specification.
  • @fgrieu First paragraph in RFC 2616 section 1.4: "The HTTP protocol is a request/response protocol" – If there’s no response, then you aren’t doing the HTTP right, which is an application protocol and as such can have different requirements than the underlying TCP protocol. Similarly, if you just send a single TCP package over the network but ignore the rest of the protocol, then you are also not automatically doing TCP just because that one package looked like it.
  • I found several solutions that included the output buffer part but it still wasn't working for me until I added those curl options. Thanks!
  • thankyou. this is best.. i tried using pThreads but need ZTS which i cannot install, i trieed GuzzleHttp (having async function name) but actually syncrhonus.. i can do async with this curl and very fast ;)
  • curl 0 timeout would let it run longer
  • If you're going to try a low timeout, use the millisecond variation curl_setopt($curl, CURLOPT_TIMEOUT_MS, 1);