diff --git a/user/httpd.c b/user/httpd.c index a5d924f..b0a741c 100644 --- a/user/httpd.c +++ b/user/httpd.c @@ -319,8 +319,18 @@ static void ICACHE_FLASH_ATTR httpdSendResp(HttpdConnData *conn) { //Parse a line of header data and modify the connection data accordingly. static void ICACHE_FLASH_ATTR httpdParseHeader(char *h, HttpdConnData *conn) { int i; -// os_printf("Got header %s\n", h); - if (os_strncmp(h, "GET ", 4)==0 || os_strncmp(h, "POST ", 5)==0) { + char first_line = false; + // os_printf("Got header %s\n", h); + + if (os_strncmp(h, "GET ", 4)==0){ + conn->requestType = GET; + first_line = true; + }else if(os_strncmp(h, "POST ", 5)==0) { + conn->requestType = POST; + first_line = true; + } + + if(first_line){ char *e; //Skip past the space after POST/GET diff --git a/user/httpd.h b/user/httpd.h index 0e929c4..8efd9b3 100644 --- a/user/httpd.h +++ b/user/httpd.h @@ -11,6 +11,9 @@ #define HTTPD_CGI_NOTFOUND 2 #define HTTPD_CGI_AUTHENTICATED 2 //for now +#define GET 1 +#define POST 2 + typedef struct HttpdPriv HttpdPriv; typedef struct HttpdConnData HttpdConnData; @@ -19,6 +22,7 @@ typedef int (* cgiSendCallback)(HttpdConnData *connData); //A struct describing a http connection. This gets passed to cgi functions. struct HttpdConnData { struct espconn *conn; + char requestType; char *url; char *getArgs; const void *cgiArg;