简体   繁体   English

GitHub API速率限制不超过Apache HttpClient

[英]GitHub API rate limit does not exceed with Apache HttpClient

I make requests to GitHub API. 我向GitHub API发出请求。

When I use this code, rate limit decreases by one on every call. 当我使用此代码时,每个呼叫的速率限制都会降低1。

new URL(url).openStream()

But when I use Apache HttpClient library, it does not. 但是当我使用Apache HttpClient库时,它不会。

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? 那怎么可能呢?

How can that be possible? 那怎么可能呢?

From the API's side -- the rate limit will not be decreased for 304 responses: 从API的角度来看-对于304个响应,速率限制不会降低:

https://developer.github.com/v3/#conditional-requests 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. 因此,如果您使用的HTTP库正在发出条件请求,而这些请求的结果为304,则速率限制将不会改变。

Does that explain things perhaps? 这也许可以解释事情吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM