Skip to content

HTTP Semantics References

Redirects

ts
redirectPolicy({ allow: [307, 308], follow303: false });

Rate Limiting

ts
import { retry } from '@unireq/core';
import { httpRetryPredicate, rateLimitDelay } from '@unireq/http';

retry(
  httpRetryPredicate({ statusCodes: [429, 503] }),
  [rateLimitDelay({ maxWait: 60000 })],
  { tries: 3 }
);

Range Requests

  • 206 Partial Content — Server sends requested byte range (MDN, RFC 7233)
  • 416 Range Not Satisfiable — Invalid range (MDN, RFC 7233 §4.4)
  • Accept-Ranges: bytes — Server supports ranges (MDN)
ts
range({ start: 0, end: 1023 }); // Request first 1KB
resume({ downloaded: 5000 }); // Resume from byte 5000

Multipart Form Data

  • RFC 7578multipart/form-data (spec)
ts
multipart(
  [{ name: 'file', filename: 'doc.pdf', data: blob, contentType: 'application/pdf' }],
  [{ name: 'title', value: 'My Document' }]
);

OAuth 2.0 Bearer

  • RFC 6750 — Bearer token usage (spec)
ts
oauthBearer({
  tokenSupplier: async () => getAccessToken(),
  skew: 60, // Clock skew tolerance (seconds)
  autoRefresh: true // Refresh on 401
});

← Body & Parsing · Core Package →

Released under the MIT License.