Sarah Marsh / HTTPServer

Dependents:   RPC_HTTP RPC_HTTP_WIZnetInterface RPC_HTTP rpc_over_http_TL_interrupter_gatePJ

Fork of HTTPServer by Henry Leinen

Revision:
5:dc88012caef1
Parent:
4:d065642c32cc
Child:
6:fe661fa9d18a
diff -r d065642c32cc -r dc88012caef1 Handler/HTTPFsRequestHandler.cpp
--- a/Handler/HTTPFsRequestHandler.cpp	Tue May 28 21:20:58 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/* HTTPFsRequestHandler.cpp */
-#include "mbed.h"
-#include "HTTPFsRequestHandler.h"
-
-
-#define _DEBUG 1
-
-#if (_DEBUG && !defined(TARGET_LPC11U24))
-#define INFO(x, ...) std::printf("[HTTPFsRequestHandler : DBG]"x"\r\n", ##__VA_ARGS__);
-#define WARN(x, ...) std::printf("[HTTPFsRequestHandler : DBG]"x"\r\n", ##__VA_ARGS__);
-#define ERR(x, ...) std::printf("[HTTPFsRequestHandler : DBG]"x"\r\n", ##__VA_ARGS__);
-#else
-#define INFO(x, ...)
-#define WARN(x, ...)
-#define ERR(x, ...)
-#endif
-
-
-#define MAX_BUFFERSIZE  128
-static char buffer[MAX_BUFFERSIZE];
-
-
-std::map<const char*, const char*> HTTPFsRequestHandler::m_fsMap;
- 
-HTTPFsRequestHandler::HTTPFsRequestHandler(const char* rootPath, const char* localPath, HTTPConnection::HTTPMessage& Msg, TCPSocketConnection& Tcp)
-    : HTTPRequestHandler(Msg, Tcp)
-{
-    m_rootPath = rootPath;
-    m_localPath = localPath;
-    
-    //  Now replace the virtual root path with a mounted device path
-    std::map<const char*, const char*>::iterator it;
-    for (it = m_fsMap.begin() ; it != m_fsMap.end() ; it++) {
-        //  find best match (if the given logical path is containted in the root
-        if (m_rootPath.find( it->second ) == 0) {
-            m_rootPath = it->first;
-            break;
-        }
-    }
-    
-    handleRequest();
-}
-
-HTTPFsRequestHandler::~HTTPFsRequestHandler()
-{
-}
-
-int HTTPFsRequestHandler::handleGetRequest()
-{
-    INFO("Handling Get Request.");
-    int retval = 200;   //success
-    std::string reqPath;
-
-    //  Check if we received a directory with the local bath
-    if ((m_localPath.length() == 0) || (m_localPath.substr( m_localPath.length()-1, 1) == "/")) {
-        //  yes, we shall append the default page name
-        m_localPath += "index.html";
-    }
-    
-    reqPath = m_rootPath + m_localPath;
-    
-    INFO("Mapping \"%s\" to \"%s\"", msg.uri.c_str(), reqPath.c_str());
-        
-    FILE *fp = fopen(reqPath.c_str(), "r");
-    if (fp != NULL) {
-        //  File was found and can be returned
-    
-        //  first determine the size
-        fseek(fp, 0, SEEK_END);
-        long size = ftell(fp);
-        fseek(fp, 0, SEEK_SET);
-    
-        startResponse(200, size);
-        while(!feof(fp) && !ferror(fp)) {
-            int cnt = fread(buffer, 1, MAX_BUFFERSIZE , fp);
-            processResponse(cnt, buffer);
-        }
-        endResponse();
-        fclose(fp);
-    }
-    else {
-        retval = 404;
-        ERR("Requested file was not found !");
-    }
-    
-    return retval;
-}
-
-int HTTPFsRequestHandler::handlePostRequest()
-{
-    return 404;
-}
-
-int HTTPFsRequestHandler::handlePutRequest()
-{
-    return 404;
-}
\ No newline at end of file