ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SimpleHandler.cpp Source File

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, TCPSocketConnection* pTCPSocketConnection) : HTTPRequestHandler(rootPath, path, pTCPSocketConnection)
00027 {
00028 #ifdef _DEBUG_SIMPLE_HANDLER
00029     printf("++++(SimpleHeandler)Initialize\r\n");
00030 #endif
00031 }
00032 
00033 SimpleHandler::~SimpleHandler()
00034 {
00035 #ifdef _DEBUG_SIMPLE_HANDLER
00036     printf("++++(SimpleHeandler)Handler destroyed\r\n");
00037 #endif
00038 }
00039 
00040 void SimpleHandler::doGet()
00041 {
00042 #ifdef _DEBUG_SIMPLE_HANDLER
00043     printf("++++(SimpleHeandler) doGet()\r\n");
00044 #endif
00045     const char* resp = "Hello world !";
00046     setContentLen( strlen(resp) );
00047     //respHeaders()["Connection"] = "close";
00048     addRespHeaders("Connection", "close");
00049     writeData(resp, strlen(resp));
00050 #ifdef _DEBUG_SIMPLE_HANDLER
00051     printf("++++(SimpleHeandler) doGet Exit\r\n");
00052 #endif
00053 }
00054 
00055 void SimpleHandler::doPost()
00056 {
00057 
00058 }
00059 
00060 void SimpleHandler::doHead()
00061 {
00062 
00063 }
00064 
00065 
00066 void SimpleHandler::onReadable() //Data has been read
00067 {
00068 
00069 }
00070 
00071 void SimpleHandler::onWriteable() //Data has been written & buf is free
00072 {
00073 #ifdef _DEBUG_SIMPLE_HANDLER
00074     printf("++++(SimpleHeandler)onWriteable() event\r\n");
00075 #endif
00076 //    close(); //Data written, we can close the connection
00077 }
00078 
00079 void SimpleHandler::onClose() //Connection is closing
00080 {
00081     //Nothing to do
00082 }
00083