Skip to content

Commit

Permalink
fix: rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdev01 committed Nov 17, 2024
1 parent 2a56087 commit bfcf834
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public Response get(String url) throws ConnectionException {

return new Response(
responseBody,
response.getStatusLine().getStatusCode()
response.getStatusLine().getStatusCode(),
response.getAllHeaders()
);
} catch (IOException ex) {
Logger.getLogger(ApacheHttpClient.class.getName()).log(Level.SEVERE, null, ex);
Expand All @@ -69,7 +70,8 @@ public Response delete(String url) {
String responseBody = EntityUtils.toString(entity);
return new Response(
responseBody,
response.getStatusLine().getStatusCode()
response.getStatusLine().getStatusCode(),
response.getAllHeaders()
);
} catch (IOException ex) {
Logger.getLogger(ApacheHttpClient.class.getName()).log(Level.SEVERE, null, ex);
Expand All @@ -90,7 +92,8 @@ public Response post(String url, String body) throws ConnectionException {

return new Response(
EntityUtils.toString(response.getEntity()),
response.getStatusLine().getStatusCode()
response.getStatusLine().getStatusCode(),
response.getAllHeaders()
);
} catch (IOException ex) {
Logger.getLogger(ApacheHttpClient.class.getName()).log(Level.SEVERE, null, ex);
Expand All @@ -111,7 +114,8 @@ public Response put(String url, String body) throws ConnectionException {

return new Response(
EntityUtils.toString(response.getEntity()),
response.getStatusLine().getStatusCode()
response.getStatusLine().getStatusCode(),
response.getAllHeaders()
);
} catch (IOException ex) {
Logger.getLogger(ApacheHttpClient.class.getName()).log(Level.SEVERE, null, ex);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/github/jpdev/asaassdk/http/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ public RateLimitData getRateLimit() {
}

private String findHeaderValue(String key) {
Optional<Header> headerEncontrado = Arrays.stream(headers)
if (headers == null) return null;

Optional<Header> headerValue = Arrays.stream(headers)
.filter(header -> header.getName().equals(key))
.findFirst();
return headerEncontrado.map(NameValuePair::getValue).orElse(null);
return headerValue.map(NameValuePair::getValue).orElse(null);
}
}

0 comments on commit bfcf834

Please sign in to comment.