Adaptation of the HttpServer by user yueee_yt. This version has improved handling of the HTTP headers (**NOTE**: There are limitations with this implementation and it is not fully functional. Use it only as a starting point.)

Dependents:   DMSupport DMSupport DMSupport DMSupport

Fork of DM_HttpServer by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Mon Nov 04 14:29:37 2019 +0000
Revision:
11:9dcff8cf906a
Parent:
10:c1c8276af541
More updates related to mbed OS 5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yueee_yt 4:1b6b021ee21d 1 //#define _DEBUG_ALL
yueee_yt 4:1b6b021ee21d 2
yueee_yt 0:fdf9c2c5200f 3 #ifndef HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 4 #define HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 5
yueee_yt 4:1b6b021ee21d 6 #ifdef _DEBUG_ALL
yueee_yt 4:1b6b021ee21d 7 #define _DEBUG_HTTP_SERVER_H
yueee_yt 4:1b6b021ee21d 8 #endif
yueee_yt 4:1b6b021ee21d 9
yueee_yt 0:fdf9c2c5200f 10 #include <string>
yueee_yt 0:fdf9c2c5200f 11 using std::string;
yueee_yt 0:fdf9c2c5200f 12
yueee_yt 0:fdf9c2c5200f 13 #include <map>
yueee_yt 0:fdf9c2c5200f 14 using std::map;
yueee_yt 0:fdf9c2c5200f 15
yueee_yt 0:fdf9c2c5200f 16 #include "HTTPRequestHandler.h"
yueee_yt 0:fdf9c2c5200f 17 #include "rtos.h"
yueee_yt 0:fdf9c2c5200f 18 #include "mbed.h"
yueee_yt 0:fdf9c2c5200f 19 #include "EthernetInterface.h"
yueee_yt 0:fdf9c2c5200f 20 //#include "HTTPRequestDispatcher.h"
yueee_yt 0:fdf9c2c5200f 21
yueee_yt 0:fdf9c2c5200f 22 //#include "dbg/dbg.h"
yueee_yt 0:fdf9c2c5200f 23
yueee_yt 0:fdf9c2c5200f 24 #define THREAD_MAX 5
yueee_yt 0:fdf9c2c5200f 25 Thread *threads[THREAD_MAX];
yueee_yt 0:fdf9c2c5200f 26 Thread *xthread;
yueee_yt 0:fdf9c2c5200f 27 //#include "HTTPServer2.h"
yueee_yt 0:fdf9c2c5200f 28
yueee_yt 0:fdf9c2c5200f 29 struct handlersComp { //Used to order handlers in the right way
yueee_yt 0:fdf9c2c5200f 30 bool operator() (const string& handler1, const string& handler2) const {
yueee_yt 0:fdf9c2c5200f 31 //The first handler is longer than the second one
yueee_yt 0:fdf9c2c5200f 32 if (handler1.length() > handler2.length())
yueee_yt 0:fdf9c2c5200f 33 return true; //Returns true if handler1 is to appear before handler2
yueee_yt 0:fdf9c2c5200f 34 else if (handler1.length() < handler2.length())
yueee_yt 0:fdf9c2c5200f 35 return false;
yueee_yt 0:fdf9c2c5200f 36 else //To avoid the == case, sort now by address
yueee_yt 0:fdf9c2c5200f 37 return ((&handler1)>(&handler2));
yueee_yt 0:fdf9c2c5200f 38 }
yueee_yt 0:fdf9c2c5200f 39 };
yueee_yt 0:fdf9c2c5200f 40
embeddedartists 11:9dcff8cf906a 41 map< string, HTTPRequestHandler*(*)(const char*, const char* , TCPSocket* ), handlersComp > m_lpHandlers;
yueee_yt 0:fdf9c2c5200f 42 template<typename T>
yueee_yt 0:fdf9c2c5200f 43 void HTTPServerAddHandler(const char* path) //Template decl in header
yueee_yt 0:fdf9c2c5200f 44 {
yueee_yt 0:fdf9c2c5200f 45 m_lpHandlers[path] = &T::inst;
yueee_yt 0:fdf9c2c5200f 46 }
yueee_yt 0:fdf9c2c5200f 47
yueee_yt 0:fdf9c2c5200f 48 void ListenThread(void const *args);
yueee_yt 0:fdf9c2c5200f 49 enum HTTP_METH {
yueee_yt 0:fdf9c2c5200f 50 HTTP_GET,
yueee_yt 0:fdf9c2c5200f 51 HTTP_POST,
yueee_yt 0:fdf9c2c5200f 52 HTTP_HEAD
yueee_yt 0:fdf9c2c5200f 53 };
yueee_yt 0:fdf9c2c5200f 54
embeddedartists 11:9dcff8cf906a 55 bool getRequest(TCPSocket* client,string* path, string* meth)
yueee_yt 0:fdf9c2c5200f 56 {
yueee_yt 0:fdf9c2c5200f 57 char req[128];
yueee_yt 0:fdf9c2c5200f 58 char c_path[128];
yueee_yt 0:fdf9c2c5200f 59 char c_meth[128];
yueee_yt 0:fdf9c2c5200f 60 const int maxLen = 128;
yueee_yt 0:fdf9c2c5200f 61 char* p = req;
yueee_yt 0:fdf9c2c5200f 62 //Read Line
yueee_yt 0:fdf9c2c5200f 63 int ret;
yueee_yt 0:fdf9c2c5200f 64 int len = 0;
yueee_yt 0:fdf9c2c5200f 65 for(int i = 0; i < maxLen - 1; i++) {
embeddedartists 11:9dcff8cf906a 66 ret = client->recv(p, 1);
yueee_yt 0:fdf9c2c5200f 67 if(!ret) {
yueee_yt 0:fdf9c2c5200f 68 break;
yueee_yt 0:fdf9c2c5200f 69 }
yueee_yt 0:fdf9c2c5200f 70 if( (len > 1) && *(p-1)=='\r' && *p=='\n' ) {
yueee_yt 0:fdf9c2c5200f 71 p--;
yueee_yt 0:fdf9c2c5200f 72 len-=2;
yueee_yt 0:fdf9c2c5200f 73 break;
yueee_yt 0:fdf9c2c5200f 74 } else if( *p=='\n' ) {
yueee_yt 0:fdf9c2c5200f 75 len--;
yueee_yt 0:fdf9c2c5200f 76 break;
yueee_yt 0:fdf9c2c5200f 77 }
yueee_yt 0:fdf9c2c5200f 78 p++;
yueee_yt 0:fdf9c2c5200f 79 len++;
yueee_yt 0:fdf9c2c5200f 80 }
yueee_yt 0:fdf9c2c5200f 81 *p = 0;
yueee_yt 4:1b6b021ee21d 82 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 83 printf("Parsing request : %s\r\n", req);
yueee_yt 4:1b6b021ee21d 84 #endif
yueee_yt 0:fdf9c2c5200f 85 ret = sscanf(req, "%s %s HTTP/%*d.%*d", c_meth, c_path);
yueee_yt 0:fdf9c2c5200f 86 if(ret !=2) return false;
yueee_yt 0:fdf9c2c5200f 87 *meth = string(c_meth);
yueee_yt 0:fdf9c2c5200f 88 *path = string(c_path);
yueee_yt 0:fdf9c2c5200f 89 return true;
yueee_yt 0:fdf9c2c5200f 90 }
yueee_yt 0:fdf9c2c5200f 91
embeddedartists 11:9dcff8cf906a 92 void dispatchRequest(TCPSocket* client)
yueee_yt 0:fdf9c2c5200f 93 {
yueee_yt 0:fdf9c2c5200f 94 string path;
yueee_yt 0:fdf9c2c5200f 95 string meth;
yueee_yt 0:fdf9c2c5200f 96 HTTP_METH methCode;
yueee_yt 4:1b6b021ee21d 97 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 98 printf("Dispatching req\r\n");
yueee_yt 4:1b6b021ee21d 99 #endif
yueee_yt 0:fdf9c2c5200f 100 if( !getRequest(client,&path, &meth ) ) {
yueee_yt 4:1b6b021ee21d 101 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 102 printf("dispatchRequest Invalid request\r\n");
yueee_yt 4:1b6b021ee21d 103 #endif
yueee_yt 0:fdf9c2c5200f 104 //close();
yueee_yt 0:fdf9c2c5200f 105 return; //Invalid request
yueee_yt 0:fdf9c2c5200f 106 }
yueee_yt 0:fdf9c2c5200f 107 if( !meth.compare("GET") ) {
yueee_yt 4:1b6b021ee21d 108 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 109 printf("dispatchRequest HTTP_GET\r\n");
yueee_yt 4:1b6b021ee21d 110 #endif
yueee_yt 0:fdf9c2c5200f 111 methCode = HTTP_GET;
yueee_yt 0:fdf9c2c5200f 112 } else if( !meth.compare("POST") ) {
yueee_yt 4:1b6b021ee21d 113 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 114 printf("dispatchRequest HTTP_POST\r\n");
yueee_yt 4:1b6b021ee21d 115 #endif
yueee_yt 0:fdf9c2c5200f 116 methCode = HTTP_POST;
yueee_yt 0:fdf9c2c5200f 117 } else if( !meth.compare("HEAD") ) {
yueee_yt 4:1b6b021ee21d 118 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 119 printf("dispatchRequest HTTP_HEAD\r\n");
yueee_yt 4:1b6b021ee21d 120 #endif
yueee_yt 0:fdf9c2c5200f 121 methCode = HTTP_HEAD;
yueee_yt 0:fdf9c2c5200f 122 } else {
yueee_yt 4:1b6b021ee21d 123 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 124 printf("dispatchRequest() Parse error\r\n");
yueee_yt 4:1b6b021ee21d 125 #endif
yueee_yt 0:fdf9c2c5200f 126 //close(); //Parse error
yueee_yt 0:fdf9c2c5200f 127 return;
yueee_yt 0:fdf9c2c5200f 128 }
yueee_yt 4:1b6b021ee21d 129 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 130 printf("Looking for a handler\r\n");
yueee_yt 4:1b6b021ee21d 131 #endif
embeddedartists 11:9dcff8cf906a 132 map< string, HTTPRequestHandler*(*)(const char*, const char*, TCPSocket*) >::iterator it;
yueee_yt 0:fdf9c2c5200f 133 int root_len = 0;
yueee_yt 0:fdf9c2c5200f 134 for (it = m_lpHandlers.begin(); it != m_lpHandlers.end(); it++) {
yueee_yt 4:1b6b021ee21d 135 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 136 printf("Checking %s...\r\n", (*it).first.c_str());
yueee_yt 4:1b6b021ee21d 137 #endif
yueee_yt 0:fdf9c2c5200f 138 root_len = (*it).first.length();
yueee_yt 0:fdf9c2c5200f 139 if ( root_len &&
yueee_yt 0:fdf9c2c5200f 140 !path.compare( 0, root_len, (*it).first ) &&
yueee_yt 0:fdf9c2c5200f 141 (path[root_len] == '/' || path[root_len] == '\0')) {
yueee_yt 4:1b6b021ee21d 142 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 143 printf("Found (%s)\r\n", (*it).first.c_str());
yueee_yt 4:1b6b021ee21d 144 #endif
yueee_yt 0:fdf9c2c5200f 145 // Found!
yueee_yt 0:fdf9c2c5200f 146 break; // for
yueee_yt 0:fdf9c2c5200f 147 }
yueee_yt 0:fdf9c2c5200f 148 }
yueee_yt 0:fdf9c2c5200f 149 if((it == m_lpHandlers.end()) && !(m_lpHandlers.empty())) {
yueee_yt 4:1b6b021ee21d 150 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 151 printf("Using default handler\r\n");
yueee_yt 4:1b6b021ee21d 152 #endif
yueee_yt 0:fdf9c2c5200f 153 it = m_lpHandlers.end();
yueee_yt 0:fdf9c2c5200f 154 it--; //Get the last element
yueee_yt 0:fdf9c2c5200f 155 if( ! (((*it).first.length() == 0) || !(*it).first.compare("/")) ) //This is not the default handler
yueee_yt 0:fdf9c2c5200f 156 it = m_lpHandlers.end();
yueee_yt 0:fdf9c2c5200f 157 root_len = 0;
yueee_yt 0:fdf9c2c5200f 158 }
yueee_yt 0:fdf9c2c5200f 159 if(it == m_lpHandlers.end()) {
yueee_yt 4:1b6b021ee21d 160 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 161 printf("No handler found\r\n");
yueee_yt 4:1b6b021ee21d 162 #endif
yueee_yt 0:fdf9c2c5200f 163 return;
yueee_yt 0:fdf9c2c5200f 164 }
yueee_yt 4:1b6b021ee21d 165 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 166 printf("Handler found.\r\n");
yueee_yt 4:1b6b021ee21d 167 #endif
yueee_yt 0:fdf9c2c5200f 168 HTTPRequestHandler* pHdlr = (*it).second((*it).first.c_str(), path.c_str() + root_len, client);
yueee_yt 0:fdf9c2c5200f 169 //**** client = NULL; //We don't own it anymore
yueee_yt 0:fdf9c2c5200f 170 switch(methCode) {
yueee_yt 0:fdf9c2c5200f 171 case HTTP_GET:
yueee_yt 0:fdf9c2c5200f 172 pHdlr->doGet();
yueee_yt 0:fdf9c2c5200f 173 break;
yueee_yt 0:fdf9c2c5200f 174 case HTTP_POST:
yueee_yt 0:fdf9c2c5200f 175 pHdlr->doPost();
yueee_yt 0:fdf9c2c5200f 176 break;
yueee_yt 0:fdf9c2c5200f 177 case HTTP_HEAD:
yueee_yt 0:fdf9c2c5200f 178 pHdlr->doHead();
yueee_yt 0:fdf9c2c5200f 179 break;
yueee_yt 0:fdf9c2c5200f 180 }
yueee_yt 0:fdf9c2c5200f 181 delete pHdlr;
yueee_yt 4:1b6b021ee21d 182 // delete client;
yueee_yt 4:1b6b021ee21d 183 // delete m_pTCPSocketConnection;
yueee_yt 4:1b6b021ee21d 184 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 4:1b6b021ee21d 185 printf("(dispatcherRequest)return\r\n");
yueee_yt 4:1b6b021ee21d 186 #endif
yueee_yt 4:1b6b021ee21d 187 return ;
yueee_yt 0:fdf9c2c5200f 188 }
yueee_yt 0:fdf9c2c5200f 189
yueee_yt 0:fdf9c2c5200f 190 void HTTPServerChild (void const *arg)
yueee_yt 0:fdf9c2c5200f 191 {
yueee_yt 4:1b6b021ee21d 192 #ifdef _DEBUG_HTTP_SERVER_H
embeddedartists 11:9dcff8cf906a 193 SocketAddress remoteAddress;
yueee_yt 0:fdf9c2c5200f 194 printf("HTTPServerChiled Start......\r\n");
yueee_yt 4:1b6b021ee21d 195 #endif
embeddedartists 11:9dcff8cf906a 196 TCPSocket* client = (TCPSocket*)arg;
yueee_yt 0:fdf9c2c5200f 197
yueee_yt 0:fdf9c2c5200f 198 for (;;) {
yueee_yt 4:1b6b021ee21d 199 #ifdef _DEBUG_HTTP_SERVER_H
embeddedartists 11:9dcff8cf906a 200 client->getpeername(&remoteAddress);
embeddedartists 11:9dcff8cf906a 201 printf("(HTTPServer.h<HTTPServerChild>)Connection from %s\r\n", remoteAddress.get_ip_address());
yueee_yt 4:1b6b021ee21d 202 #endif
yueee_yt 0:fdf9c2c5200f 203 dispatchRequest(client);
yueee_yt 4:1b6b021ee21d 204 #ifdef _DEBUG_HTTP_SERVER_H
embeddedartists 11:9dcff8cf906a 205 client->getpeername(&remoteAddress);
embeddedartists 11:9dcff8cf906a 206 printf("(HTTPServer.h<HTTPServerChild>)Close %s\r\n", remoteAddress.get_ip_address());
yueee_yt 4:1b6b021ee21d 207 #endif
yueee_yt 0:fdf9c2c5200f 208 client->close();
embeddedartists 11:9dcff8cf906a 209 // client->reset_address();
yueee_yt 0:fdf9c2c5200f 210 //delete client;
embeddedartists 11:9dcff8cf906a 211 ThisThread::flags_wait_any(1);
yueee_yt 0:fdf9c2c5200f 212 }
yueee_yt 0:fdf9c2c5200f 213 }
yueee_yt 0:fdf9c2c5200f 214
yueee_yt 0:fdf9c2c5200f 215 void HTTPServerCloser (void const *arg)
yueee_yt 0:fdf9c2c5200f 216 {
embeddedartists 11:9dcff8cf906a 217 #ifdef _DEBUG_HTTP_SERVER_H
embeddedartists 11:9dcff8cf906a 218 SocketAddress remoteAddress;
embeddedartists 11:9dcff8cf906a 219 #endif
embeddedartists 11:9dcff8cf906a 220 TCPSocket *client = (TCPSocket*)arg;
yueee_yt 0:fdf9c2c5200f 221
yueee_yt 0:fdf9c2c5200f 222 for (;;) {
embeddedartists 11:9dcff8cf906a 223 #ifdef _DEBUG_HTTP_SERVER_H
embeddedartists 11:9dcff8cf906a 224 client->getpeername(&remoteAddress);
embeddedartists 11:9dcff8cf906a 225 printf("Close %s, %x\r\n", remoteAddress.get_ip_address(), client);
embeddedartists 11:9dcff8cf906a 226 #endif
yueee_yt 0:fdf9c2c5200f 227 client->close();
embeddedartists 11:9dcff8cf906a 228 ThisThread::flags_wait_any(1);
yueee_yt 0:fdf9c2c5200f 229 }
yueee_yt 0:fdf9c2c5200f 230 }
yueee_yt 0:fdf9c2c5200f 231
yueee_yt 0:fdf9c2c5200f 232 void HTTPServerStart(int port = 80)
yueee_yt 0:fdf9c2c5200f 233 {
yueee_yt 0:fdf9c2c5200f 234 int i, t = 0;
embeddedartists 11:9dcff8cf906a 235 nsapi_error_t ret;
embeddedartists 11:9dcff8cf906a 236 TCPSocket* clients[THREAD_MAX];
embeddedartists 11:9dcff8cf906a 237 TCPSocket* xclient;
yueee_yt 0:fdf9c2c5200f 238
yueee_yt 0:fdf9c2c5200f 239 for (i = 0; i < THREAD_MAX; i ++) {
yueee_yt 0:fdf9c2c5200f 240 threads[i] = NULL;
yueee_yt 0:fdf9c2c5200f 241 }
yueee_yt 0:fdf9c2c5200f 242 xthread = NULL;
yueee_yt 0:fdf9c2c5200f 243
embeddedartists 11:9dcff8cf906a 244 TCPSocket server;
embeddedartists 11:9dcff8cf906a 245
embeddedartists 11:9dcff8cf906a 246
embeddedartists 11:9dcff8cf906a 247 ret = server.open(NetworkInterface::get_default_instance());
embeddedartists 11:9dcff8cf906a 248 if (ret != NSAPI_ERROR_OK) {
embeddedartists 11:9dcff8cf906a 249 printf("HTTPServer: open failed %d\n", ret);
embeddedartists 11:9dcff8cf906a 250 return;
embeddedartists 11:9dcff8cf906a 251 }
embeddedartists 11:9dcff8cf906a 252
embeddedartists 11:9dcff8cf906a 253 ret = server.bind(port);
embeddedartists 11:9dcff8cf906a 254 if (ret != NSAPI_ERROR_OK) {
embeddedartists 11:9dcff8cf906a 255 printf("HTTPServer: bind failed %d\n", ret);
embeddedartists 11:9dcff8cf906a 256 return;
embeddedartists 11:9dcff8cf906a 257 }
yueee_yt 0:fdf9c2c5200f 258 server.listen();
yueee_yt 4:1b6b021ee21d 259 // server.set_blocking(false);
yueee_yt 4:1b6b021ee21d 260 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 261 printf("Wait for new connection...\r\n");
yueee_yt 4:1b6b021ee21d 262 #endif
yueee_yt 0:fdf9c2c5200f 263 for (;;) {
yueee_yt 4:1b6b021ee21d 264 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 265 printf("**Start Loop** \r\n");
yueee_yt 4:1b6b021ee21d 266 #endif
yueee_yt 0:fdf9c2c5200f 267 if (t >= 0) {
embeddedartists 11:9dcff8cf906a 268
embeddedartists 11:9dcff8cf906a 269 clients[t] = server.accept();
embeddedartists 11:9dcff8cf906a 270 //if(server.accept(clients[t])==0) {
embeddedartists 11:9dcff8cf906a 271 if (clients[t] != NULL) {
yueee_yt 0:fdf9c2c5200f 272 // fork child process
yueee_yt 0:fdf9c2c5200f 273 if (threads[t]) {
embeddedartists 11:9dcff8cf906a 274 threads[t]->flags_set(1);
yueee_yt 0:fdf9c2c5200f 275 } else {
embeddedartists 11:9dcff8cf906a 276
embeddedartists 11:9dcff8cf906a 277 threads[t] = new Thread(osPriorityNormal, OS_STACK_SIZE*2);
embeddedartists 11:9dcff8cf906a 278 if (threads[t] != NULL) {
embeddedartists 11:9dcff8cf906a 279
embeddedartists 11:9dcff8cf906a 280 threads[t]->start(callback(HTTPServerChild, (void*)clients[t]));
embeddedartists 11:9dcff8cf906a 281 }
yueee_yt 0:fdf9c2c5200f 282 }
yueee_yt 4:1b6b021ee21d 283 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 284 printf("Forked %d\r\n", t);
yueee_yt 4:1b6b021ee21d 285 #endif
yueee_yt 0:fdf9c2c5200f 286 }
yueee_yt 0:fdf9c2c5200f 287 } else {
embeddedartists 11:9dcff8cf906a 288 xclient = server.accept();
embeddedartists 11:9dcff8cf906a 289 //if(server.accept(xclient)==0) {
embeddedartists 11:9dcff8cf906a 290 if (xclient != NULL) {
yueee_yt 0:fdf9c2c5200f 291 // closer process
yueee_yt 0:fdf9c2c5200f 292 if (xthread) {
embeddedartists 11:9dcff8cf906a 293 xthread->flags_set(1);
yueee_yt 0:fdf9c2c5200f 294 } else {
embeddedartists 11:9dcff8cf906a 295 xthread = new Thread(osPriorityNormal, OS_STACK_SIZE*2);
embeddedartists 11:9dcff8cf906a 296 if (xthread != NULL) {
embeddedartists 11:9dcff8cf906a 297 xthread->start(callback(HTTPServerChild, (void*)xclient));
embeddedartists 11:9dcff8cf906a 298 }
yueee_yt 0:fdf9c2c5200f 299 }
yueee_yt 4:1b6b021ee21d 300 #ifdef _DEBUG_HTTP_SERVER_H
yueee_yt 0:fdf9c2c5200f 301 printf("Connection full\r\n");
yueee_yt 4:1b6b021ee21d 302 #endif
yueee_yt 0:fdf9c2c5200f 303 }
yueee_yt 0:fdf9c2c5200f 304 }
yueee_yt 0:fdf9c2c5200f 305
yueee_yt 0:fdf9c2c5200f 306 t = -1;
yueee_yt 0:fdf9c2c5200f 307 for (i = 0; i < THREAD_MAX; i ++) {
embeddedartists 11:9dcff8cf906a 308 if (threads[i] == NULL || threads[i]->get_state() == Thread::WaitingThreadFlag) {
yueee_yt 0:fdf9c2c5200f 309 if (t < 0) t = i; // next empty thread
yueee_yt 0:fdf9c2c5200f 310 }
yueee_yt 0:fdf9c2c5200f 311 }
yueee_yt 4:1b6b021ee21d 312 // Thread::wait(100);
yueee_yt 0:fdf9c2c5200f 313 }
yueee_yt 0:fdf9c2c5200f 314 }
embeddedartists 10:c1c8276af541 315 //#include "Handler/RPCHandler.h"
yueee_yt 0:fdf9c2c5200f 316 #include "Handler/FSHandler.h"
yueee_yt 0:fdf9c2c5200f 317 #include "Handler/SimpleHandler.h"
yueee_yt 0:fdf9c2c5200f 318
yueee_yt 0:fdf9c2c5200f 319 #endif