Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f7fc8ab

Browse filesBrowse files
authored
Use HTTP method table from ESP-IDF's nghttp (espressif#4900)
Fixes: espressif#4884 * Use HTTP method table from ESP-IDF's nghttp * Parse methods using IDF's HTTP method list * Make example's loops to allow the CPU to switch tasks
1 parent dd834b3 commit f7fc8ab
Copy full SHA for f7fc8ab

File tree

Expand file treeCollapse file tree

11 files changed

+32
-22
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+32
-22
lines changed

‎libraries/WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ void setup(void) {
125125

126126
void loop(void) {
127127
server.handleClient();
128+
delay(2);//allow the cpu to switch to other tasks
128129
}
129130

130131
void drawGraph() {

‎libraries/WebServer/examples/FSBrowser/FSBrowser.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/FSBrowser/FSBrowser.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,5 @@ void setup(void) {
300300

301301
void loop(void) {
302302
server.handleClient();
303+
delay(2);//allow the cpu to switch to other tasks
303304
}

‎libraries/WebServer/examples/HelloServer/HelloServer.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/HelloServer/HelloServer.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ void setup(void) {
7070

7171
void loop(void) {
7272
server.handleClient();
73+
delay(2);//allow the cpu to switch to other tasks
7374
}

‎libraries/WebServer/examples/HttpAdvancedAuth/HttpAdvancedAuth.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/HttpAdvancedAuth/HttpAdvancedAuth.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ void setup() {
5656
void loop() {
5757
ArduinoOTA.handle();
5858
server.handleClient();
59+
delay(2);//allow the cpu to switch to other tasks
5960
}

‎libraries/WebServer/examples/HttpBasicAuth/HttpBasicAuth.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/HttpBasicAuth/HttpBasicAuth.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ void setup() {
3838
void loop() {
3939
ArduinoOTA.handle();
4040
server.handleClient();
41+
delay(2);//allow the cpu to switch to other tasks
4142
}

‎libraries/WebServer/examples/PathArgServer/PathArgServer.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/PathArgServer/PathArgServer.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ void setup(void) {
5353

5454
void loop(void) {
5555
server.handleClient();
56+
delay(2);//allow the cpu to switch to other tasks
5657
}

‎libraries/WebServer/examples/SDWebServer/SDWebServer.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/SDWebServer/SDWebServer.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,5 @@ void setup(void) {
310310

311311
void loop(void) {
312312
server.handleClient();
313+
delay(2);//allow the cpu to switch to other tasks
313314
}

‎libraries/WebServer/examples/SimpleAuthentification/SimpleAuthentification.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/SimpleAuthentification/SimpleAuthentification.ino
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ void setup(void) {
129129

130130
void loop(void) {
131131
server.handleClient();
132+
delay(2);//allow the cpu to switch to other tasks
132133
}

‎libraries/WebServer/examples/WebUpdate/WebUpdate.ino

Copy file name to clipboardExpand all lines: libraries/WebServer/examples/WebUpdate/WebUpdate.ino
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ void setup(void) {
6565

6666
void loop(void) {
6767
server.handleClient();
68-
delay(1);
68+
delay(2);//allow the cpu to switch to other tasks
6969
}

‎libraries/WebServer/src/HTTP_Method.h

Copy file name to clipboard
+4-10Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#ifndef _HTTP_Method_H_
22
#define _HTTP_Method_H_
33

4-
typedef enum {
5-
HTTP_GET = 0b00000001,
6-
HTTP_POST = 0b00000010,
7-
HTTP_DELETE = 0b00000100,
8-
HTTP_PUT = 0b00001000,
9-
HTTP_PATCH = 0b00010000,
10-
HTTP_HEAD = 0b00100000,
11-
HTTP_OPTIONS = 0b01000000,
12-
HTTP_ANY = 0b01111111,
13-
} HTTPMethod;
4+
#include "http_parser.h"
5+
6+
typedef enum http_method HTTPMethod;
7+
#define HTTP_ANY (HTTPMethod)(255)
148

159
#endif /* _HTTP_Method_H_ */

‎libraries/WebServer/src/Parsing.cpp

Copy file name to clipboardExpand all lines: libraries/WebServer/src/Parsing.cpp
+19-11Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
#define WEBSERVER_MAX_POST_ARGS 32
3131
#endif
3232

33+
#define __STR(a) #a
34+
#define _STR(a) __STR(a)
35+
const char * _http_method_str[] = {
36+
#define XX(num, name, string) _STR(name),
37+
HTTP_METHOD_MAP(XX)
38+
#undef XX
39+
};
40+
3341
static const char Content_Type[] PROGMEM = "Content-Type";
3442
static const char filename[] PROGMEM = "filename";
3543

@@ -96,17 +104,17 @@ bool WebServer::_parseRequest(WiFiClient& client) {
96104
_currentUri = url;
97105
_chunked = false;
98106

99-
HTTPMethod method = HTTP_GET;
100-
if (methodStr == F("POST")) {
101-
method = HTTP_POST;
102-
} else if (methodStr == F("DELETE")) {
103-
method = HTTP_DELETE;
104-
} else if (methodStr == F("OPTIONS")) {
105-
method = HTTP_OPTIONS;
106-
} else if (methodStr == F("PUT")) {
107-
method = HTTP_PUT;
108-
} else if (methodStr == F("PATCH")) {
109-
method = HTTP_PATCH;
107+
HTTPMethod method = HTTP_ANY;
108+
size_t num_methods = sizeof(_http_method_str) / sizeof(const char *);
109+
for (size_t i=0; i<num_methods; i++) {
110+
if (methodStr == _http_method_str[i]) {
111+
method = (HTTPMethod)i;
112+
break;
113+
}
114+
}
115+
if (method == HTTP_ANY) {
116+
log_e("Unknown HTTP Method: %s", methodStr.c_str());
117+
return false;
110118
}
111119
_currentMethod = method;
112120

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.