Not easy to get the number of methods llhttp has
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 237
- PR merge metrics
- No merged PRs in 30d
Description
In aiohttp, we need to create an array of all the method names that llhttp supports for caching purposes.
The problem is that llhttp_method_name abort()s on an out-of-range id (api.c:222), our old code therefore just had a hardcoded constant set to 46 and iterated over them. But, this means when llhttp added the QUERY method, our code didn't pick it up.
Would it be reasonable to add something to llhttp to trivially get this information? Either allowing llhttp_method_name to return NULL rather than abort(), or adding a constant that tells us how many methods are available.
Without something like that, I've had to add this awkward thing to extract the names directly:
https://github.com/aio-libs/aiohttp/pull/13174/changes#diff-061b5abe803b659aa544700e4065e1fbff6e83112315e345ea2d2e31ad1d6ca7R106-R117
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at api.c:222 and trace how llhttp_method_name handles method IDs and how the supported method table is defined. Review the existing API and the aiohttp example linked in the issue, then determine which enumeration behavior is appropriate. Done means callers can discover every supported method, including newly added methods, without a hardcoded count or aborting lookup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 54/100