Skip to content

HTTP client class #2

Description

@zefir-git

A base class used for making HTTP requests.

Will need setting user agent. User agent will be set by lib users, not the lib itself. A user agent is required by modrinth.

Will need way to seamlessly retry failed requests. By rule of thumb, everything with Retry-After should be retried after that time. Rate limit errors (429) also use these headers:

  • RateLimit-Reset
  • X-RateLimit-Reset

Need to track number of attempts so we don't retry forever. So e.g. if a request will take over 30s in total (i.e. current time spent retrying + next retry time is over 30s) should stop retrying and exit with error.

Any other HTTP errors should just throw right away.

Just for reference, this was my TS code: https://github.com/modpm/lib-ts/blob/main/src/HTTPClient.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions