Skip to content

Introduce request#isMethod(...) to check the http method of the request (fixes #398)#399

Closed
mathieucarbou wants to merge 1 commit intomainfrom
rpi-fix
Closed

Introduce request#isMethod(...) to check the http method of the request (fixes #398)#399
mathieucarbou wants to merge 1 commit intomainfrom
rpi-fix

Conversation

@mathieucarbou
Copy link
Member

Fixes #398

Note: this PR does not fix the definition in arduino-pico.

Instead, it provides a new way to check for a request method, and this way is implemented differently in PICO.

If users are still reegistering their handler in PICO with | like that

webServer.on("/ping", HTTP_GET | HTTP_POST, [](AsyncWebServerRequest* request) {
  request->send(200, "text/plain", "pong");
});

then of course it won't solve anything.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces AsyncWebServerRequest::isMethod(...) to provide correct HTTP method matching across platforms, specifically addressing RP2040/RP2350 where request methods are not a bitmask and &-based checks produce false positives (issue #398).

Changes:

  • Added AsyncWebServerRequest::isMethod(WebRequestMethodComposite) with RP2040/RP2350-specific semantics (equality / HTTP_ANY).
  • Updated handler method checks to use request->isMethod(...) instead of bitwise &.
  • Updated methodToString() to use isMethod(...) for method name resolution.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/ESPAsyncWebServer.h Adds AsyncWebServerRequest::isMethod(...) with RP2040/RP2350-specific handling.
src/WebHandlers.cpp Switches handler method filtering to request->isMethod(_method) to avoid RP false positives.
src/WebRequest.cpp Updates methodToString() to rely on isMethod(...) instead of & checks.
src/AsyncJson.cpp Changes JSON handler method filtering logic (but currently introduces a behavior regression by ignoring _method).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mathieucarbou mathieucarbou marked this pull request as draft March 9, 2026 15:00
@mathieucarbou mathieucarbou force-pushed the rpi-fix branch 2 times, most recently from ebe1f84 to e8fbf42 Compare March 9, 2026 15:15
@mathieucarbou
Copy link
Member Author

Closing in favor of #400

@mathieucarbou mathieucarbou deleted the rpi-fix branch March 9, 2026 17:22
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.

HTTP Method matching is incorrect on RP2040 / RP2350

2 participants