ttezel / twit

Twitter API Client for node (REST & Streaming API)
4.31k stars 568 forks source link

No rate limit information provided for POST calls? #489

Closed tarngerine closed 5 years ago

tarngerine commented 5 years ago

Related to #28, I'm able to get rate limit info like x-rate-limit-reset from GET calls like users/show, but specifically for POST calls friendships/destroy or friendships/create I'm not able to see the headers.

Was it intentional to not show x-rate-limit-reset, etc. headers for POST? Or does Twitter not provide them?

Related info:


Example: POST friendships/create > cannot see headers

{ statusCode: 200,
  body: undefined,
  headers: 
   { 'cache-control': 'no-cache, no-store, must-revalidate, pre-check=0, post-check=0',
     connection: 'close',
     'content-disposition': 'attachment; filename=json.json',
     'content-encoding': 'gzip',
     'content-length': '1483',
     'content-type': 'application/json;charset=utf-8',
     date: 'Sat, 26 Jan 2019 22:42:34 GMT',
     expires: 'Tue, 31 Mar 1981 05:00:00 GMT',
     'last-modified': 'Sat, 26 Jan 2019 22:42:34 GMT',
     pragma: 'no-cache',
     server: 'tsa_b',
     'set-cookie':...,
     status: '200 OK',
     'strict-transport-security': 'max-age=631138519',
     'x-access-level': 'read-write',
     'x-connection-hash': 'c838c559dbd9d361004d0b2568bae6ad',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'SAMEORIGIN',
     'x-response-time': '115',
     'x-transaction': '000006e1005dbbd3',
     'x-twitter-response-tags': 'BouncerCompliant',
     'x-xss-protection': '1; mode=block; report=https://twitter.com/i/xss_report' },
  request: 
   { uri: 
      Url {...},
     method: 'POST',
     headers: 
      { Accept: '*/*',
        'User-Agent': 'twit-client',
        'Content-type': 'application/json',
        'accept-encoding': 'gzip, deflate',
        Authorization: '...',
        'content-length': 0 } } }

Example: GET users/show headers > can see headers

{ statusCode: 200,
  body: undefined,
  headers: 
   { 'cache-control': 'no-cache, no-store, must-revalidate, pre-check=0, post-check=0',
     connection: 'close',
     'content-disposition': 'attachment; filename=json.json',
     'content-encoding': 'gzip',
     'content-length': '1487',
     'content-type': 'application/json;charset=utf-8',
     date: 'Sat, 26 Jan 2019 22:42:31 GMT',
     expires: 'Tue, 31 Mar 1981 05:00:00 GMT',
     'last-modified': 'Sat, 26 Jan 2019 22:42:31 GMT',
     pragma: 'no-cache',
     server: 'tsa_b',
     'set-cookie': ...,
     status: '200 OK',
     'strict-transport-security': 'max-age=631138519',
     'x-access-level': 'read-write',
     'x-connection-hash': 'xxx',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'SAMEORIGIN',
     'x-rate-limit-limit': '900',
     'x-rate-limit-remaining': '896',
     'x-rate-limit-reset': '1548543378',
     'x-response-time': '53',
     'x-transaction': 'xxx',
     'x-twitter-response-tags': 'BouncerCompliant',
     'x-xss-protection': '1; mode=block; report=https://twitter.com/i/xss_report' },
  request: 
   { uri: 
      Url { ... },
     method: 'GET',
     headers: 
      { Accept: '*/*',
        'User-Agent': 'twit-client',
        'Content-type': 'application/json',
        'accept-encoding': 'gzip, deflate',
        Authorization: ... } } }
tarngerine commented 5 years ago

Okay, I'm guessing this is a Twitter issue not a Twit issue. Seems like they don't really share POST rate limits anywhere since it's dynamic

maziyarpanahi commented 5 years ago

Thanks for sharing, if you don't mind please close the issue.