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

pull/30/head
Ben Pirt 9 years ago
parent e80e1862a8
commit 92b27fd615
  1. 14
      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.
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

@ -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;

Loading…
Cancel
Save