private fork
Fork of GSwifiInterface by
Diff: GSwifi/GSwifi_httpd.cpp
- Revision:
- 16:105b56570533
- Parent:
- 15:086d1a33a197
- Child:
- 18:20970aec3ad3
--- a/GSwifi/GSwifi_httpd.cpp Thu Jan 30 15:10:14 2014 +0000 +++ b/GSwifi/GSwifi_httpd.cpp Tue Mar 04 15:01:38 2014 +0000 @@ -42,13 +42,20 @@ switch (_httpd[cid].mode) { case HTTPDMODE_REQUEST: - if (_con[cid].buf == NULL) +#ifndef CFG_ENABLE_RTOS + if (_con[cid].buf == NULL) { _con[cid].buf = new CircBuffer<char>(CFG_DATA_SIZE); + } +#endif _httpd[cid].buf = _con[cid].buf; - _httpd[cid].buf->flush(); + if (_httpd[cid].buf != NULL) { + _httpd[cid].buf->flush(); + } _httpd[cid].keepalive = 0; if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { - _httpd[cid].buf->queue(c); + if (_httpd[cid].buf != NULL) { + _httpd[cid].buf->queue(c); + } _httpd[cid].mode = HTTPDMODE_REQUEST_STR; } break; @@ -66,7 +73,9 @@ _httpd[cid].enter = 0; break; default: - _httpd[cid].buf->queue(c); + if (_httpd[cid].buf != NULL) { + _httpd[cid].buf->queue(c); + } break; } break; @@ -76,7 +85,7 @@ case 0x0d: // CR break; case 0x0a: // LF - if (_httpd[cid].buf->available() == 0) { + if (_httpd[cid].buf != NULL && _httpd[cid].buf->available() == 0) { // if ((_httpd[cid].enter == 0x0d && c == 0x0a) || (_httpd[cid].enter == 0x0a && c == 0x0a)) { if (_httpd[cid].enter == 0x0a && c == 0x0a) { _httpd[cid].buf->flush(); @@ -104,16 +113,20 @@ _httpd[cid].enter = c; break; default: - _httpd[cid].buf->queue(c); + if (_httpd[cid].buf != NULL) { + _httpd[cid].buf->queue(c); + } _httpd[cid].enter = 0; break; } break; case HTTPDMODE_BODY: - _httpd[cid].buf->queue(c); - if (_httpd[cid].buf->available() >= _httpd[cid].length) { - _httpd[cid].mode = HTTPDMODE_ENTER; - _con[cid].received = true; + if (_httpd[cid].buf != NULL) { + _httpd[cid].buf->queue(c); + if (_httpd[cid].buf->available() >= _httpd[cid].length) { + _httpd[cid].mode = HTTPDMODE_ENTER; + _con[cid].received = true; + } } break; #ifdef CFG_ENABLE_WEBSOCKET @@ -175,6 +188,7 @@ int i, j, len; char buf[CFG_CMD_SIZE]; + if (_httpd[cid].buf == NULL) return 0; for (len = 0; len < sizeof(buf); len++) { if (_httpd[cid].buf->dequeue(&buf[len]) == false) break; } @@ -241,6 +255,8 @@ {"Sec-WebSocket-Version:", &GSwifi::reqWebSocketVersion}, {"Sec-WebSocket-Key:", &GSwifi::reqWebSocketKey}, }; + + if (_httpd[cid].buf == NULL) return 0; for (i = 0; i < sizeof(buf); i++) { if (_httpd[cid].buf->dequeue(&buf[i]) == false) break; }