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.
            Asked
            
        
        
            Active
            
        
            Viewed 4,926 times
        
    3
            
            
        - 
                    1Isn't just leaving out a `load` listener (`XMLHttpRequest`) or a `.then` (`Fetch`) enough? ā CertainPerformance Oct 04 '18 at 21:13
- 
                    2"as it still waits for a response". Whatever you use, you always have to wait for a HTTP response. ā Ram Oct 04 '18 at 21:15
- 
                    Have a look at this https://stackoverflow.com/q/8612364/9727047 ā Nikhil Oct 04 '18 at 21:39
3 Answers
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.
 
    
    
        SunLightGirl99
        
- 25
- 11
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
        
- 944
- 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
        
- 4,296
- 3
- 27
- 34
