public void getEvents(String streamId, long startTime, long endTime, int limit,
Function<? super StreamEvent, Boolean> callback) throws IOException, StreamNotFoundException {
URL url = config.resolveURL(String.format("streams/%s/events?start=%d&end=%d&limit=%d",
streamId, startTime, endTime, limit));
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
AccessToken accessToken = config.getAccessToken();
if (accessToken != null) {
urlConn.setRequestProperty(HttpHeaders.AUTHORIZATION, accessToken.getTokenType() + " " + accessToken.getValue());
}
if (urlConn instanceof HttpsURLConnection && !config.getDefaultConfig().isVerifySSLCert()) {
try {
HttpRequests.disableCertCheck((HttpsURLConnection) urlConn);