Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ratelimit methods not working as expected #122

Open
barrettkingram opened this issue Oct 22, 2020 · 1 comment
Open

ratelimit methods not working as expected #122

barrettkingram opened this issue Oct 22, 2020 · 1 comment
Labels
status: help wanted requesting help from the community type: bug bug in the library type: community enhancement feature request not on Twilio's roadmap

Comments

@barrettkingram
Copy link

Issue Summary

Response#ratelimit is not working as expected. It just returns nil every time. I believe this is because of a header capitalization mismatch between what that method expects and what is actually returned.

Code Snippet

sendgrid_client = SendGrid::API.new(api_key: SENDGRID_API_KEY).client
data = {automatic_security: true, custom_spf: false, default: false, domain: "my-test-domain.com", subdomain: "abc"}.stringify_keys
response = sendgrid_client.whitelabel.domains.post(request_body: data)

# This returns nil
response.headers["X-RateLimit-Limit"]

# This returns ["1"]
response.headers["x-ratelimit-limit"]

# This returns nil
response.ratelimit

Technical details:

  • ruby-http-client version: 3.5.1
  • ruby version: 2.5
@eshanholtz
Copy link
Contributor

@barrettkingram

Looking at the docs for Net::HttpHeader, it states that the keys should be case-insensitive, but looking at this relevant StackOverflow post, reading the header hash (which is done to populate response headers under the hood) returns lower-cased keys. This appears to be causing issues as we construct the RateLimit object in ruby_http_client.rb. The fix here would be updating L72-74 to use the lower cased header key.

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

@eshanholtz eshanholtz added status: help wanted requesting help from the community type: bug bug in the library type: community enhancement feature request not on Twilio's roadmap labels Oct 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: bug bug in the library type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

2 participants