Expose the request type to the CGI functions so we can act based on its value

v0.9.0
Ben Pirt 10 years ago
parent e80e1862a8
commit 92b27fd615
  1. 12
      user/httpd.c
  2. 4
      user/httpd.h

@ -319,8 +319,18 @@ static void ICACHE_FLASH_ATTR httpdSendResp(HttpdConnData *conn) {
//Parse a line of header data and modify the connection data accordingly. //Parse a line of header data and modify the connection data accordingly.
static void ICACHE_FLASH_ATTR httpdParseHeader(char *h, HttpdConnData *conn) { static void ICACHE_FLASH_ATTR httpdParseHeader(char *h, HttpdConnData *conn) {
int i; int i;
char first_line = false;
// os_printf("Got header %s\n", h); // os_printf("Got header %s\n", h);
if (os_strncmp(h, "GET ", 4)==0 || os_strncmp(h, "POST ", 5)==0) {
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; char *e;
//Skip past the space after POST/GET //Skip past the space after POST/GET

@ -11,6 +11,9 @@
#define HTTPD_CGI_NOTFOUND 2 #define HTTPD_CGI_NOTFOUND 2
#define HTTPD_CGI_AUTHENTICATED 2 //for now #define HTTPD_CGI_AUTHENTICATED 2 //for now
#define GET 1
#define POST 2
typedef struct HttpdPriv HttpdPriv; typedef struct HttpdPriv HttpdPriv;
typedef struct HttpdConnData HttpdConnData; 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. //A struct describing a http connection. This gets passed to cgi functions.
struct HttpdConnData { struct HttpdConnData {
struct espconn *conn; struct espconn *conn;
char requestType;
char *url; char *url;
char *getArgs; char *getArgs;
const void *cgiArg; const void *cgiArg;

Loading…
Cancel
Save