GitHub API rate limit does not exceed with Apache HttpClient

518 views Asked by At

I make requests to GitHub API.

When I use this code, rate limit decreases by one on every call.

new URL(url).openStream()

But when I use Apache HttpClient library, it does not.

HttpGet httpGet = new HttpGet();
httpGet.setURI(new URL(url).toURI());
HttpClient httpClient = HttpClientBuilder.create().build();
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream inputStream = entity.getContent();

How can that be possible?

1

There are 1 answers

1
Ivan Zuzak On

How can that be possible?

From the API's side -- the rate limit will not be decreased for 304 responses:

https://developer.github.com/v3/#conditional-requests

So, if the HTTP library you're using is making conditional requests and those requests result in a 304, then the rate limit will not change.

Does that explain things perhaps?