As the title says, I would like to know how to send an HTTP request using HTTPClient with the OPTIONS method in Java. I have looked at the HTTP methods that can be used (GET, POST, PUT and DELETE) and I have not seen this option. An example of a GET/POST request with HTTPClient would be like this:
String uri = "https://www.stackoverflow.com/"
HttpRequest.Builder preRequest=null;
// EXAMPLE OF GET REQUEST
preRequest = HttpRequest.newBuilder()
.uri(URI.create( uri ))
.GET();
// EXAMPLE OF POST REQUEST
preRequest = HttpRequest.newBuilder()
.uri(URI.create( uri ))
.POST(BodyPublishers.ofString(req.getBody())); // "req" is an object of a class made by me, it does not matter in this context
In case it can't be used (which would seem extremely rare to me), what alternative can I use?
Thank you very much in advance!