4141#include < ESPAsyncTCP.h>
4242#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
4343#include < RPAsyncTCP.h>
44- #include < HTTP_Method.h>
45- #include < http_parser.h>
4644#else
4745#error Platform not supported
4846#endif
@@ -80,11 +78,10 @@ class AsyncCallbackWebHandler;
8078class AsyncResponseStream ;
8179class AsyncMiddlewareChain ;
8280
83- #if defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
84- typedef enum http_method WebRequestMethod;
85- #else
86- #ifndef WEBSERVER_H
87- typedef enum {
81+ // Namespace for web request method defines
82+ namespace AsyncWebRequestMethod {
83+ // The long name here is because we sometimes include this in the global namespace
84+ enum AsyncWebRequestMethodType {
8885 HTTP_GET = 0b0000000000000001 ,
8986 HTTP_POST = 0b0000000000000010 ,
9087 HTTP_DELETE = 0b0000000000000100 ,
@@ -101,8 +98,25 @@ typedef enum {
10198 HTTP_COPY = 0b0010000000000000 ,
10299 HTTP_RESERVED = 0b0100000000000000 ,
103100 HTTP_ANY = 0b0111111111111111 ,
104- } WebRequestMethod;
105- #endif
101+ };
102+ }; // namespace AsyncWebRequestMethod
103+
104+ typedef AsyncWebRequestMethod::AsyncWebRequestMethodType WebRequestMethod;
105+ typedef uint16_t WebRequestMethodComposite;
106+
107+ // Type-safe helper functions for composite methods
108+ extern inline WebRequestMethodComposite operator |(WebRequestMethodComposite l, WebRequestMethod r) {
109+ return l | static_cast <WebRequestMethodComposite>(r);
110+ };
111+ extern inline WebRequestMethodComposite operator |(WebRequestMethod l, WebRequestMethod r) {
112+ return static_cast <WebRequestMethodComposite>(l) | r;
113+ };
114+
115+ #if !defined(ASYNCWEBSERVER_NO_GLOBAL_HTTP_METHODS) && !defined(WEBSERVER_H)
116+ // Import the method enum values to the global namespace
117+ // This will collide with some <webserver.h> values on some platforms;
118+ // for historical reasons they are assumed to be compatible.
119+ using namespace AsyncWebRequestMethod ;
106120#endif
107121
108122#ifndef HAVE_FS_FILE_OPEN_MODE
@@ -122,7 +136,6 @@ class FileOpenMode {
122136#define RESPONSE_TRY_AGAIN 0xFFFFFFFF
123137#define RESPONSE_STREAM_BUFFER_SIZE 1460
124138
125- typedef uint16_t WebRequestMethodComposite;
126139typedef std::function<void (void )> ArDisconnectHandler;
127140
128141/*
0 commit comments