3

I need to create a http post request without waiting for a response in either Java or JavaScript. Async http calls is not what Iā€™m looking for as it still waits for a response, just on a separate thread.

Ramonster
  • 434
  • 3
  • 14

3 Answers3

0

It looks like this post might help you.

Depending on what client you are using, you should be able to just invoke the post method(). I could be wrong but I believe adding the .then() is what makes it asynchronous.

Sending HTTP POST Request In Java

0

Yes, it is possible if you create your own connection send whatever you need and just kill the connection after. The answer by Alan Geleynse from Java - sending HTTP parameters via POST method easily does that.

Charles
  • 904
  • 5
  • 9
0

yes, it possible,
i was done it before when i working with laravel and i need lots of webhook send to merchans. before i write login waiting for response but it's take more time then i google and find the solution. here is example.

function postCurlRequest(string $url, array $post_array, $check_ssl=true) {
    // $url = 'https://post_url.com';
    $cmd = "curl -L -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 &"; // don't wait for response

    // echo $cmd;die;

    exec($cmd, $output, $exit);
   return $exit == 0;
}
Harsukh Makwana
  • 3,420
  • 2
  • 22
  • 29