+++ /dev/null
-// Copyright (c) 2012 Dennco Project
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-//
-// Created by tkawata on 1/28/2012.
-//
-
-#ifndef dennco_DNServerImpl_h
-#define dennco_DNServerImpl_h
-
-#include "DNServer.h"
-
-class DNEngine;
-
-class DNServerImpl
-{
-public:
- static DNServerImpl* create(DNEngine *engine, unsigned int portNumber, DNClientRequestHandler handler);
- virtual bool isRunning() = 0;
- virtual void start() = 0;
- virtual void stop() = 0;
-
-};
-
-
-#endif
+++ /dev/null
-// Copyright (c) 2012 Dennco Project
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-//
-// Created by tkawata on 1/28/2012.
-//
-
-#include "DNSimpleWebServerImpl.h"
-
-#include <string>
-
-//static
-DNHTTPRequest* DNSimpleWebServerImpl::parseHttpRequest(const char *message)
-{
- size_t len = strlen(message);
-
- bool isPost = false;
- bool isValid = true;
- std::string path;
- std::string host;
- int contentLen = 0;
- std::string postbody;
-
- const char *p;
- if (len < 5)
- {
- //illegal message
- return NULL;
- }
- if (strncmp(message, "POST ", 5) == 0)
- {
- //POST message
- p = message + 4;
- isPost = true;
- }
- else if (strncmp(message, "GET ", 4) == 0)
- {
- //GET message
- p = message + 3;
- isPost = false;
- }
- else
- {
- //non supported message
- isValid = false;
- }
-
- //get URI
- if (isValid)
- {
- while (*p && *p == ' ' && *p != '\r' && *p != '\n')
- {
- p++;
- }
- if (!*p || *p == '\r' || *p == '\n')
- {
- isValid = false;
- }
- else
- {
- const char *s = p;
- while (*p && *p != ' ' && *p != '\r' && *p != '\n')
- p++;
-
- if (*p != ' ' && p - s < 1)
- {
- isValid = false;
- }
- else
- {
- path = std::string(s, p - s);
- }
- }
- }
-
- if (isValid)
- {
- while(*p)
- {
- if (*p == '\n' && *(p-1) == '\r')
- {
- break;
- }
- p++;
- }
- if (!*p)
- isValid = false;
- }
-
- if (isValid)
- {
- p++;
- const char *hs = p;
- const char *he = p-1;
- while (*p)
- {
- if (*p == '\n' && *(p-1) == '\r' && *(p-2) == '\n')
- {
- he = p;
- }
- p++;
- }
-
- p = hs;
- while(p <= he && *p)
- {
- if (*p == ':')
- {
- //Host:
- if (p-hs >= 5 && strncmp("Host", p-4, 4))
- {
- p++;
- const char *tmp = p;
- while(p <= hs && *p && *p !='\r')
- {
- p++;
- }
- if (tmp < p - 1)
- {
- host = std::string(tmp, p - tmp - 1);
- }
- }
-
- //Content-Length:
- if (p-hs >= 15 && strncmp("Content-Length", p-14,14))
- {
- p++;
- const char *tmp = p;
- while(p <= hs && *p && *p !='\r')
- {
- p++;
- }
- if (tmp < p - 1)
- {
- contentLen = atoi(std::string(tmp, p - tmp - 1).c_str());
- }
- }
- }
-
- p++;
- }
-
- //POST BODY
- if (isPost && contentLen>0)
- {
- int bl = 0;
- const char *ps = he+1;
- while (*(ps + bl) && bl < contentLen)
- {
- bl++;
- }
-
- postbody = std::string(ps, bl);
- }
- }
-
- if (isValid)
- {
- DNHTTPRequest *request = new DNHTTPRequest();
- request->isPost = isPost;
- request->uri = path;
- if (isPost)
- {
- request->postData = postbody;
- }
- return request;
- }
- else
- {
- return NULL;
- }
-}
-
+++ /dev/null
-// Copyright (c) 2012 Dennco Project
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-//
-// Created by tkawata on 1/28/2012.
-//
-
-#ifndef dennco_DNSimpleWebServer_h
-#define dennco_DNSimpleWebServer_h
-
-#include <string>
-
-#include "DNServerImpl.h"
-
-class DNHTTPRequest
-{
-public:
- std::string uri;
- bool isPost;
- std::string postData;
-};
-
-class DNSimpleWebServerImpl : public DNServerImpl
-{
- static DNHTTPRequest* parseHttpRequest(const char *message);
-};
-
-#endif
+++ /dev/null
-// Copyright (c) 2012 Dennco Project
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-//
-// Created by tkawata on 1/29/2012.
-//
-
-#ifndef dennco_OSXDNServerImpl_h
-#define dennco_OSXDNServerImpl_h
-
-#include "DNSimpleWebServerImpl.h"
-
-class OSXDNSimpleWebServerImpl : public DNSimpleWebServerImpl
-{
-public:
- virtual bool isRunning();
- virtual void start();
- virtual void stop();
-
-};
-
-#endif
+++ /dev/null
-// Copyright (c) 2012 Dennco Project
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-//
-// Created by tkawata on 1/29/2012.
-//
-
-
-#include "OSXDNSimpleWebServerImpl.h"
-
-DNServerImpl* DNServerImpl::create(DNEngine *engine, unsigned int portNumber, DNClientRequestHandler handler)
-{
- //TODO
- return NULL;
-}
-
-bool OSXDNSimpleWebServerImpl::isRunning()
-{
- //TODO
- return false;
-}
-
-void OSXDNSimpleWebServerImpl::start()
-{
- //TODO
-}
-
-void OSXDNSimpleWebServerImpl::stop()
-{
- //TODO
-}