Simple HTTP Server with one page index.html stored inside MBED as char vector and javascript to update a table content

Fork of HTTP_SERVER by Akifumi Takahashi

Committer:
aktk
Date:
Fri Mar 16 21:55:50 2018 +0000
Revision:
13:b6dd6ed0060b
Parent:
1:3a1fe94c6e42
merged

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aktk 0:cc483bea4fe3 1 /* ResponseMessenger.h */
aktk 0:cc483bea4fe3 2 #ifndef RESPONSE_MESSENGER_H
aktk 0:cc483bea4fe3 3 #define RESPONSE_MESSENGER_H
aktk 0:cc483bea4fe3 4 #include "mbed.h"
aktk 0:cc483bea4fe3 5 #include "string.h"
aktk 0:cc483bea4fe3 6 #include "EthernetInterface.h"
aktk 0:cc483bea4fe3 7 #include "FileHandler.h"
aktk 0:cc483bea4fe3 8 #include <stdlib.h>
aktk 0:cc483bea4fe3 9 using namespace std;
aktk 0:cc483bea4fe3 10
aktk 0:cc483bea4fe3 11 class ResponseMessenger
aktk 0:cc483bea4fe3 12 {
aktk 0:cc483bea4fe3 13 enum {
aktk 0:cc483bea4fe3 14 REASON_PHRASE_SIZE = 32,
aktk 0:cc483bea4fe3 15 HEADER_FIELDS_SIZE = 2048
aktk 0:cc483bea4fe3 16 };
aktk 0:cc483bea4fe3 17 public:
aktk 0:cc483bea4fe3 18 ResponseMessenger();
aktk 0:cc483bea4fe3 19 ~ResponseMessenger();
aktk 0:cc483bea4fe3 20 int resetHeader();
aktk 0:cc483bea4fe3 21 int setStatusLine(int,const char*);
aktk 0:cc483bea4fe3 22 int setHeaderField(const char*, const char*);
aktk 0:cc483bea4fe3 23 int setHeaderField(const char*, int);
aktk 1:3a1fe94c6e42 24 int rmHeaderField(const char*);
aktk 1:3a1fe94c6e42 25 int getStatusCode();
aktk 0:cc483bea4fe3 26 /**
aktk 0:cc483bea4fe3 27 * Function to send response messages.
aktk 0:cc483bea4fe3 28 * just header only
aktk 0:cc483bea4fe3 29 * @return char
aktk 0:cc483bea4fe3 30 * @retval error code
aktk 0:cc483bea4fe3 31 */
aktk 0:cc483bea4fe3 32 char sendHTTPResponse(TCPSocketConnection&);
aktk 0:cc483bea4fe3 33 /**
aktk 0:cc483bea4fe3 34 * Function to send response messages.
aktk 0:cc483bea4fe3 35 * @return char
aktk 0:cc483bea4fe3 36 * @retval error code
aktk 0:cc483bea4fe3 37 */
aktk 0:cc483bea4fe3 38 char sendHTTPResponse(TCPSocketConnection&, FileHandler&);
aktk 0:cc483bea4fe3 39 private:
aktk 0:cc483bea4fe3 40 // Status-Line
aktk 0:cc483bea4fe3 41 static const char http_ver[9];
aktk 0:cc483bea4fe3 42 int status_code;
aktk 0:cc483bea4fe3 43 char reason_phrase[REASON_PHRASE_SIZE];
aktk 0:cc483bea4fe3 44 // Header Field buffer
aktk 0:cc483bea4fe3 45 // - General Header
aktk 0:cc483bea4fe3 46 // - Response Header
aktk 0:cc483bea4fe3 47 // - Entity Header
aktk 0:cc483bea4fe3 48 char header_field_buffer[HEADER_FIELDS_SIZE];
aktk 0:cc483bea4fe3 49 };
aktk 0:cc483bea4fe3 50
aktk 0:cc483bea4fe3 51 #endif