The lib with which to make LPC1768 a simple HTTP server. This have not yet implemented. fopen() DOESN'T WORK after EthernetInterface::connect() is called as using mbed-os 5.4~. See also https://os.mbed.com/questions/80658/HardFault-occurs-when-fopen-is-called-af/ or https://github.com/ARMmbed/mbed-os/issues/6578 and https://github.com/ARMmbed/mbed-os/issues/6624
Fork of HTTP_SERVER by
Diff: HTTP_SERVER.cpp
- Revision:
- 6:4eb469f51570
- Parent:
- 5:dedbaa9c633b
- Child:
- 7:184c6f1ace94
diff -r dedbaa9c633b -r 4eb469f51570 HTTP_SERVER.cpp --- a/HTTP_SERVER.cpp Sat Nov 26 18:54:10 2016 +0000 +++ b/HTTP_SERVER.cpp Sat Nov 26 19:15:20 2016 +0000 @@ -91,7 +91,7 @@ case 0: printf("(HTTP_SERVER) recieved buffer is empty.\r\n"); msger.setStatusLine(400, "No Request"); - if(msger.setHeaderField("Connection", "close"))printf("(HTTP_SERVER)buffer over flow @ ResponseMessenger"); + if(msger.setHeaderField("Connection", "Close"))printf("(HTTP_SERVER)buffer over flow @ ResponseMessenger"); httpmethod = NULL; filepath = NULL; http_ver = NULL; @@ -99,7 +99,7 @@ case -1: printf("(HTTP_SERVER) failed to read data from client.\r\n"); msger.setStatusLine(500, "Internal Server Error"); - if(msger.setHeaderField("Connection", "close"))printf("(HTTP_SERVER)buffer over flow @ ResponseMessenger"); + if(msger.setHeaderField("Connection", "Close"))printf("(HTTP_SERVER)buffer over flow @ ResponseMessenger"); httpmethod = NULL; filepath = NULL; http_ver = NULL; @@ -242,6 +242,9 @@ msger.resetHeader(); printf("(HTTP_SERVER) echo back done.\r\n"); } + if (strcmp(httpmethod, NULL) == 0 ) { + msger.sendHTTPResponse(tcpcon); + } printf("(HTTP_SERVER) Response to Request has done\r\n"); } printf("(HTTP_SERVER) close connection.\r\ntcp server is listening...\r\n");