void ICACHE_FLASH_ATTR HTTPCustomStart( ) { if( strncmp( (const char*)curhttp->pathbuffer, "/d/huge", 7 ) == 0 ) { curhttp->rcb = (void(*)())&huge; curhttp->bytesleft = 0xffffffff; } else if( strncmp( (const char*)curhttp->pathbuffer, "/d/rawnow", 9 ) == 0 ) { curhttp->rcb = (void(*)())&rawnow; curhttp->bytesleft = 0xfffffffe; } else if( strncmp( (const char*)curhttp->pathbuffer, "/d/echo?", 8 ) == 0 ) { curhttp->rcb = (void(*)())&echo; curhttp->bytesleft = 0xfffffffe; } else if( strncmp( (const char*)curhttp->pathbuffer, "/d/issue?", 9 ) == 0 ) { curhttp->rcb = (void(*)())&issue; curhttp->bytesleft = 0xfffffffe; } else { curhttp->rcb = 0; curhttp->bytesleft = 0; } curhttp->isfirst = 1; HTTPHandleInternalCallback(); }
static void DoHTTP( uint8_t timed ) { switch( curhttp->state ) { case HTTP_STATE_NONE: //do nothing if no state. break; case HTTP_STATE_DATA_XFER: if( TCPCanSend( curhttp->socket, 1024 ) ) //TCPDoneSend { if( curhttp->is_dynamic ) { HTTPCustomCallback( ); } else { HTTPHandleInternalCallback( ); } } break; case HTTP_WAIT_CLOSE: if( TCPDoneSend( curhttp->socket ) ) { if( curhttp->keep_alive ) { curhttp->state = HTTP_STATE_WAIT_METHOD; } else { HTTPClose( ); } } break; case HTTP_STATE_DATA_WEBSOCKET: if( TCPCanSend( curhttp->socket, 1024 ) ) //TCPDoneSend { WebSocketTickInternal(); } break; default: if( timed ) { if( curhttp->timeout++ > HTTP_SERVER_TIMEOUT ) { HTTPClose( ); } } } }