|
|
@ -94,8 +94,9 @@ static HttpdConnData ICACHE_FLASH_ATTR *httpdFindConnData(void *arg) { |
|
|
|
for (i=0; i<MAX_CONN; i++) { |
|
|
|
for (i=0; i<MAX_CONN; i++) { |
|
|
|
if (connData[i].conn==(struct espconn *)arg) return &connData[i]; |
|
|
|
if (connData[i].conn==(struct espconn *)arg) return &connData[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//Shouldn't happen.
|
|
|
|
os_printf("FindConnData: Huh? Couldn't find connection for %p\n", arg); |
|
|
|
os_printf("FindConnData: Huh? Couldn't find connection for %p\n", arg); |
|
|
|
return NULL; //WtF?
|
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Retires a connection for re-use
|
|
|
|
//Retires a connection for re-use
|
|
|
@ -174,7 +175,6 @@ int ICACHE_FLASH_ATTR httpdGetHeader(HttpdConnData *conn, char *header, char *re |
|
|
|
p=p+strlen(p)+1; //skip HTTP part
|
|
|
|
p=p+strlen(p)+1; //skip HTTP part
|
|
|
|
while (p<(conn->priv->head+conn->priv->headPos)) { |
|
|
|
while (p<(conn->priv->head+conn->priv->headPos)) { |
|
|
|
while(*p<=32 && *p!=0) p++; //skip crap at start
|
|
|
|
while(*p<=32 && *p!=0) p++; //skip crap at start
|
|
|
|
// os_printf("Looking for %s, Header: '%s'\n", header, p);
|
|
|
|
|
|
|
|
//See if this is the header
|
|
|
|
//See if this is the header
|
|
|
|
if (os_strncmp(p, header, strlen(header))==0 && p[strlen(header)]==':') { |
|
|
|
if (os_strncmp(p, header, strlen(header))==0 && p[strlen(header)]==':') { |
|
|
|
//Skip 'key:' bit of header line
|
|
|
|
//Skip 'key:' bit of header line
|
|
|
@ -264,7 +264,6 @@ static void ICACHE_FLASH_ATTR httpdSentCb(void *arg) { |
|
|
|
HttpdConnData *conn=httpdFindConnData(arg); |
|
|
|
HttpdConnData *conn=httpdFindConnData(arg); |
|
|
|
char sendBuff[MAX_SENDBUFF_LEN]; |
|
|
|
char sendBuff[MAX_SENDBUFF_LEN]; |
|
|
|
|
|
|
|
|
|
|
|
// os_printf("Sent callback on conn %p\n", conn);
|
|
|
|
|
|
|
|
if (conn==NULL) return; |
|
|
|
if (conn==NULL) return; |
|
|
|
conn->priv->sendBuff=sendBuff; |
|
|
|
conn->priv->sendBuff=sendBuff; |
|
|
|
conn->priv->sendBuffLen=0; |
|
|
|
conn->priv->sendBuffLen=0; |
|
|
@ -449,7 +448,7 @@ static void ICACHE_FLASH_ATTR httpdReconCb(void *arg, sint8 err) { |
|
|
|
|
|
|
|
|
|
|
|
static void ICACHE_FLASH_ATTR httpdDisconCb(void *arg) { |
|
|
|
static void ICACHE_FLASH_ATTR httpdDisconCb(void *arg) { |
|
|
|
#if 0 |
|
|
|
#if 0 |
|
|
|
//Stupid esp sdk passes through wrong arg here, namely the one of the *listening* socket.
|
|
|
|
//The esp sdk passes through wrong arg here, namely the one of the *listening* socket.
|
|
|
|
//If it ever gets fixed, be sure to update the code in this snippet; it's probably out-of-date.
|
|
|
|
//If it ever gets fixed, be sure to update the code in this snippet; it's probably out-of-date.
|
|
|
|
HttpdConnData *conn=httpdFindConnData(arg); |
|
|
|
HttpdConnData *conn=httpdFindConnData(arg); |
|
|
|
os_printf("Disconnected, conn=%p\n", conn); |
|
|
|
os_printf("Disconnected, conn=%p\n", conn); |
|
|
@ -501,7 +500,7 @@ static void ICACHE_FLASH_ATTR httpdConnectCb(void *arg) { |
|
|
|
espconn_regist_sentcb(conn, httpdSentCb); |
|
|
|
espconn_regist_sentcb(conn, httpdSentCb); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Httpd initialization routine. Call this to kick off webserver functionality.
|
|
|
|
void ICACHE_FLASH_ATTR httpdInit(HttpdBuiltInUrl *fixedUrls, int port) { |
|
|
|
void ICACHE_FLASH_ATTR httpdInit(HttpdBuiltInUrl *fixedUrls, int port) { |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|