au wot hackathon0314 test program

Dependencies:   NySNICInterface mbed-rtos mbed

Fork of RESTServer_team4 by y ishida

Committer:
kanpapa
Date:
Sat Mar 14 10:58:45 2015 +0000
Revision:
10:1caf4a3ce823
Parent:
5:70c9f6045f2d
beta version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
komoritan 0:998e2e00df0c 1 #ifndef HTTP_SERVER
komoritan 0:998e2e00df0c 2 #define HTTP_SERVER
komoritan 0:998e2e00df0c 3
komoritan 0:998e2e00df0c 4 #include "mbed.h"
komoritan 0:998e2e00df0c 5 #include "SNIC_WifiInterface.h"
komoritan 0:998e2e00df0c 6 #include "TCPSocketServer.h"
komoritan 0:998e2e00df0c 7 #include "TCPSocketConnection.h"
komoritan 0:998e2e00df0c 8
komoritan 0:998e2e00df0c 9 #define HTTP_REPLY_MAX_STRING 1024
komoritan 0:998e2e00df0c 10
komoritan 0:998e2e00df0c 11 enum
komoritan 0:998e2e00df0c 12 {
komoritan 0:998e2e00df0c 13 HTTP_200_OK = 200,
komoritan 0:998e2e00df0c 14 HTTP_400_BADREQUEST = 400,
komoritan 0:998e2e00df0c 15 HTTP_404_NOTFOUND = 404
komoritan 0:998e2e00df0c 16 };
komoritan 0:998e2e00df0c 17
komoritan 0:998e2e00df0c 18
komoritan 0:998e2e00df0c 19 class HTTPServer
komoritan 0:998e2e00df0c 20 {
komoritan 0:998e2e00df0c 21 public :
komoritan 0:998e2e00df0c 22 HTTPServer();
komoritan 0:998e2e00df0c 23 virtual ~HTTPServer();
komoritan 0:998e2e00df0c 24 bool init(int port);
komoritan 0:998e2e00df0c 25 void run();
komoritan 0:998e2e00df0c 26
komoritan 0:998e2e00df0c 27 private :
komoritan 0:998e2e00df0c 28 void handle_request(char* buffer);
komoritan 0:998e2e00df0c 29 void create_response(char* buffer);
komoritan 0:998e2e00df0c 30 TCPSocketServer socketserver;
komoritan 0:998e2e00df0c 31 char reply[HTTP_REPLY_MAX_STRING];
komoritan 0:998e2e00df0c 32 int response_code;
komoritan 0:998e2e00df0c 33 };
komoritan 0:998e2e00df0c 34
komoritan 0:998e2e00df0c 35 #endif
komoritan 0:998e2e00df0c 36