Sample code for 30+ languages & platforms
Java

Send HTTPS Get Without Waiting for the Response

See more REST Examples

This example demonstrates sending an HTTP GET request without waiting for the response.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Rest;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Rest rest = new Rest();

        // Connect to the server using TLS
        boolean bAutoReconnect = false;
        try {
            rest.connect("example.com", 443, true, bAutoReconnect);

            // Send a GET request to https://example.com/some/path
            rest.sendReqNoBody("GET", "/some/path");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        // OK, the request was sent.
        // Close the connection.
        int maxWaitMs = 50;
        rest.disconnect(maxWaitMs);

        System.out.println("GET Request Sent.");
    }
}