Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Handling extension methods in a performant way #157

@jasnell

Description

@jasnell

nodejs/node-v0.x-archive#6078 (comment)

Based on a cursory scan through the current code in http_parser.c one possible approach immediately jumps out at me: handle it similar to the way you handle header field names. That is, mark the start of the method and run through your method recognition logic. If you detect one of the methods you know, fantastic, if it's not one that you recognize, set parser->method to some generic "unknown" and do a CALLBACK_DATA(...). If the callback returns an error, then the method is not recognized... throw your error and move on. If the callback returns ok, beautiful, move on. As part of this, add in a check to verify each character is a token and you should be good without any real noticeable impact on performance.

Like I said, that's just one approach that stood out given a first pass through the code. The performance concerns for parsing arbitrary http header names (which are also tokens of unbounded length) are pretty much identical to any concerns you may have about the request method so using a similar approach would seem to make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions