Skip to content

Do not mutate the request method in getMethod() - #1974

Open
abu-tahir-0 wants to merge 1 commit into
uNetworking:masterfrom
abu-tahir-0:fix/1826-getmethod-mutation
Open

abu-tahir-0 wants to merge 1 commit into
uNetworking:masterfrom
abu-tahir-0:fix/1826-getmethod-mutation

Conversation

@abu-tahir-0

Copy link
Copy Markdown

Fixes #1826

HttpParser::getMethod() normalizes the method through the HTTP_METHODS table by rewriting the stored characters in place. Any internal use of getMethod() (e.g. size checks) therefore changes the parser state, and a later getCaseSensitiveMethod() returns the lowercased method.

Change

Resolve the canonical method spelling from the lookup table without writing back into the request buffer, so getMethod() no longer mutates the parsed request.

Tests

  • New cases in tests/HttpParser.cpp assert that after getMethod(), getCaseSensitiveMethod() still returns GET, get, and PoSt exactly as sent.
  • Baseline (new tests only): fails with Method GET was mutated by getMethod().
  • Patched: the complete HttpParser test executable passes in the Docker build, including all three method-preservation checks.

getMethod() lowercases the method through the shared HTTP_METHODS table,
so a later getCaseSensitiveMethod() returns the lowercased value. Look up
the canonical spelling without writing back to the parser state.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal use of HttpRequest::getMethod modifies request for getCaseSensitiveMethod()

1 participant