I have this function httpGet() which calls http():
public static int httpGet(String url, StringBuilder response) throws IOException {
return http(url,(http)->http.setRequestMethod("GET"), response);
}
private static int http(String url, httpMethod method, StringBuilder response) throws IOException {
HttpURLConnection http = (HttpURLConnection)new URL(url).openConnection();
http.setConnectTimeout(5000);
http.setReadTimeout(5000);
method.doMethod(http);
int status = 404;
......
......
return status;
}
I want to add an additional parameter for readTimeout, which needs to be optional with a default value that will be used otherwise.
In this case readTimeout is set to 5000 for all the calls, but I want this specific call to be executed for longer timeouts.
I think I need this new parameter to be optional as I don't want to change the implementations where this http() method has been called.
This is how I call it:
Assert.assertEquals(HTTP_OK, httpGet(DEFAULT_BROWSCAP_ENDPOINT, result));
How can I implement a new optional parameter for readTimeout?