HttpServer Library for "mbed-os" which added a snapshot handler.
Dependents: GR-PEACH-webcam GR-Boards_WebCamera GR-Boards_WebCamera GR-Boards_WebCamera
Fork of HttpServer_snapshot by
SimpleHandler.cpp
00001 /* 00002 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 00011 The above copyright notice and this permission notice shall be included in 00012 all copies or substantial portions of the Software. 00013 00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 THE SOFTWARE. 00021 */ 00022 #define _DEBUG_SIMPLE_HANDLER 00023 00024 #include "SimpleHandler.h" 00025 00026 SimpleHandler::SimpleHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket) : HTTPRequestHandler(rootPath, path, pTCPSocket) 00027 { 00028 #ifdef _DEBUG_SIMPLE_HANDLER 00029 printf("++++(SimpleHeader)Initialize\r\n"); 00030 #endif 00031 } 00032 00033 SimpleHandler::~SimpleHandler() 00034 { 00035 #ifdef _DEBUG_SIMPLE_HANDLER 00036 printf("++++(SimpleHeader)Handler destroyed\r\n"); 00037 #endif 00038 } 00039 00040 void SimpleHandler::doGet() 00041 { 00042 #ifdef _DEBUG_SIMPLE_HANDLER 00043 printf("++++(SimpleHeader) doGet()\r\n"); 00044 #endif 00045 const char* resp = "Hello world !"; 00046 setContentLen( strlen(resp) ); 00047 respHeaders()["Connection"] = "close"; 00048 writeData(resp, strlen(resp)); 00049 #ifdef _DEBUG_SIMPLE_HANDLER 00050 printf("++++(SimpleHeader) doGet Exit\r\n"); 00051 #endif 00052 } 00053 00054 void SimpleHandler::doPost() 00055 { 00056 00057 } 00058 00059 void SimpleHandler::doHead() 00060 { 00061 00062 } 00063 00064 00065 void SimpleHandler::onReadable() //Data has been read 00066 { 00067 00068 } 00069 00070 void SimpleHandler::onWriteable() //Data has been written & buf is free 00071 { 00072 #ifdef _DEBUG_SIMPLE_HANDLER 00073 printf("\r\n++++SimpleHandler::onWriteable() event\r\n"); 00074 #endif 00075 // close(); //Data written, we can close the connection 00076 } 00077 00078 void SimpleHandler::onClose() //Connection is closing 00079 { 00080 //Nothing to do 00081 } 00082
Generated on Tue Jul 12 2022 21:18:29 by 1.7.2