summaryrefslogtreecommitdiffstats
path: root/WebServer
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
committerAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
commit53e22b11857fed62e2313d6d84d90f88ed412ffb (patch)
treec61e56725da7dff0154d566722651e2c39c9d6c6 /WebServer
parentWebAdmin: Removed the duplicate memory usage querying (diff)
downloadcuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.gz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.bz2
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.lz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.xz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.zst
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.zip
Diffstat (limited to '')
-rw-r--r--WebServer/Events.h36
-rw-r--r--WebServer/Globals.h30
-rw-r--r--WebServer/Socket.h254
-rw-r--r--WebServer/StdHelpers.h128
-rw-r--r--WebServer/Tracer.h226
-rw-r--r--WebServer/UrlHelper.h84
-rw-r--r--WebServer/WebServer.h216
-rw-r--r--WebServer/base64.h8
8 files changed, 491 insertions, 491 deletions
diff --git a/WebServer/Events.h b/WebServer/Events.h
index c8a6a7df9..352dc4056 100644
--- a/WebServer/Events.h
+++ b/WebServer/Events.h
@@ -1,18 +1,18 @@
-#pragma once
-
-class cEvents
-{
-public:
- cEvents( unsigned int a_NumEvents = 1 );
- ~cEvents();
-
- void Wait();
- void Set(unsigned int a_EventNum = 0);
-private:
- unsigned int m_NumEvents;
- void* m_Handle; // HANDLE[] pointer
-
-#ifndef _WIN32
- bool m_bNamed;
-#endif
-};
+#pragma once
+
+class cEvents
+{
+public:
+ cEvents( unsigned int a_NumEvents = 1 );
+ ~cEvents();
+
+ void Wait();
+ void Set(unsigned int a_EventNum = 0);
+private:
+ unsigned int m_NumEvents;
+ void* m_Handle; // HANDLE[] pointer
+
+#ifndef _WIN32
+ bool m_bNamed;
+#endif
+};
diff --git a/WebServer/Globals.h b/WebServer/Globals.h
index fd31ba703..d60f34720 100644
--- a/WebServer/Globals.h
+++ b/WebServer/Globals.h
@@ -1,15 +1,15 @@
-
-// Globals.h
-
-// This file gets included from every module in the project, so that global symbols may be introduced easily
-// Also used for precompiled header generation in MSVC environments
-
-
-
-
-
-#include "../source/Globals.h"
-
-
-
-
+
+// Globals.h
+
+// This file gets included from every module in the project, so that global symbols may be introduced easily
+// Also used for precompiled header generation in MSVC environments
+
+
+
+
+
+#include "../source/Globals.h"
+
+
+
+
diff --git a/WebServer/Socket.h b/WebServer/Socket.h
index 5f1248107..b144659c7 100644
--- a/WebServer/Socket.h
+++ b/WebServer/Socket.h
@@ -1,127 +1,127 @@
-/*
- Socket.h
-
- Copyright (C) 2002-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-#ifndef SOCKET_H
-#define SOCKET_H
-
-
-
-
-
-#ifndef _WIN32
- typedef int SOCKET;
- #define SOCKET_ERROR (-1)
- #define INVALID_SOCKET (-1)
- #define closesocket close
-#endif // !_WIN32
-
-
-
-
-
-enum TypeSocket {BlockingSocket, NonBlockingSocket};
-
-
-
-
-
-class Socket
-{
-public:
-
- virtual ~Socket();
- Socket(const Socket&);
- Socket& operator=(Socket&);
-
- std::string ReceiveLine();
- std::string ReceiveBytes( unsigned int a_Length );
-
- bool IsValid(void) const;
-
- void Close( bool a_WaitSend = false );
-
- // The parameter of SendLine is not a const reference
- // because SendLine modifes the std::string passed.
- void SendLine (std::string);
-
- // The parameter of SendBytes is a const reference
- // because SendBytes does not modify the std::string passed
- // (in contrast to SendLine).
- void SendBytes(const std::string&);
-
-protected:
- friend class SocketServer;
- friend class SocketSelect;
-
- Socket(SOCKET s);
- Socket();
-
-
- SOCKET s_;
-
- int* refCounter_;
-
-private:
- static void Start();
- static void End();
- static int nofSockets_;
-};
-
-
-
-
-
-class SocketServer :
- public Socket
-{
-public:
- SocketServer(int port, int connections, TypeSocket type=BlockingSocket);
-
- Socket* Accept();
-};
-
-
-
-
-
-// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/wsapiref_2tiq.asp
-class SocketSelect
-{
-public:
- SocketSelect(Socket const * const s1, Socket const * const s2=NULL, TypeSocket type=BlockingSocket);
-
- bool Readable(Socket const * const s);
-
-private:
- fd_set fds_;
-};
-
-#endif
+/*
+ Socket.h
+
+ Copyright (C) 2002-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+#ifndef SOCKET_H
+#define SOCKET_H
+
+
+
+
+
+#ifndef _WIN32
+ typedef int SOCKET;
+ #define SOCKET_ERROR (-1)
+ #define INVALID_SOCKET (-1)
+ #define closesocket close
+#endif // !_WIN32
+
+
+
+
+
+enum TypeSocket {BlockingSocket, NonBlockingSocket};
+
+
+
+
+
+class Socket
+{
+public:
+
+ virtual ~Socket();
+ Socket(const Socket&);
+ Socket& operator=(Socket&);
+
+ std::string ReceiveLine();
+ std::string ReceiveBytes( unsigned int a_Length );
+
+ bool IsValid(void) const;
+
+ void Close( bool a_WaitSend = false );
+
+ // The parameter of SendLine is not a const reference
+ // because SendLine modifes the std::string passed.
+ void SendLine (std::string);
+
+ // The parameter of SendBytes is a const reference
+ // because SendBytes does not modify the std::string passed
+ // (in contrast to SendLine).
+ void SendBytes(const std::string&);
+
+protected:
+ friend class SocketServer;
+ friend class SocketSelect;
+
+ Socket(SOCKET s);
+ Socket();
+
+
+ SOCKET s_;
+
+ int* refCounter_;
+
+private:
+ static void Start();
+ static void End();
+ static int nofSockets_;
+};
+
+
+
+
+
+class SocketServer :
+ public Socket
+{
+public:
+ SocketServer(int port, int connections, TypeSocket type=BlockingSocket);
+
+ Socket* Accept();
+};
+
+
+
+
+
+// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/wsapiref_2tiq.asp
+class SocketSelect
+{
+public:
+ SocketSelect(Socket const * const s1, Socket const * const s2=NULL, TypeSocket type=BlockingSocket);
+
+ bool Readable(Socket const * const s);
+
+private:
+ fd_set fds_;
+};
+
+#endif
diff --git a/WebServer/StdHelpers.h b/WebServer/StdHelpers.h
index e9efa3dc2..1011881f8 100644
--- a/WebServer/StdHelpers.h
+++ b/WebServer/StdHelpers.h
@@ -1,65 +1,65 @@
-/*
- stdHelpers.h
-
- Copyright (C) 2002-2005 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-#ifndef STDHELPERS_H__
-#define STDHELPERS_H__
-
-#include <string>
-#include <sstream>
-
-std::string ReplaceInStr(const std::string& in, const std::string& search_for, const std::string& replace_with);
-
-void ToUpper(std::string& s);
-void ToLower(std::string& s);
-
-template <class T>
-T To(std::string const& s) {
- T ret;
-
- std::stringstream stream;
- stream << s;
- stream >> ret;
-
- return ret;
-}
-
-template<class T>
-std::string StringFrom(T const& t) {
- std::string ret;
-
- std::stringstream stream;
- stream << t;
- stream >> ret;
-
- return ret;
-}
-
+/*
+ stdHelpers.h
+
+ Copyright (C) 2002-2005 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+#ifndef STDHELPERS_H__
+#define STDHELPERS_H__
+
+#include <string>
+#include <sstream>
+
+std::string ReplaceInStr(const std::string& in, const std::string& search_for, const std::string& replace_with);
+
+void ToUpper(std::string& s);
+void ToLower(std::string& s);
+
+template <class T>
+T To(std::string const& s) {
+ T ret;
+
+ std::stringstream stream;
+ stream << s;
+ stream >> ret;
+
+ return ret;
+}
+
+template<class T>
+std::string StringFrom(T const& t) {
+ std::string ret;
+
+ std::stringstream stream;
+ stream << t;
+ stream >> ret;
+
+ return ret;
+}
+
#endif \ No newline at end of file
diff --git a/WebServer/Tracer.h b/WebServer/Tracer.h
index bce350219..c13d5128f 100644
--- a/WebServer/Tracer.h
+++ b/WebServer/Tracer.h
@@ -1,113 +1,113 @@
-/*
- Tracer.h
-
- Copyright (C) 2002-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- The most current version of Tracer.h can be found at
- http://www.adp-gmbh.ch/cpp/common/Tracer.html
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-#ifndef TRACER_H__
-#define TRACER_H__
-
-#ifdef DO_TRACE
-
-#include <string>
-#include <sstream>
-
-#include <windows.h>
-
-#define StartTrace(x) TraceFunc_::StartTrace_(x)
-#define Trace(x) dummy_____for_trace_func______.Trace_(x)
-#define Trace2(x,y) dummy_____for_trace_func______.Trace_(x,y)
-#define TraceFunc(x) TraceFunc_ dummy_____for_trace_func______(x)
-#define TraceFunc2(x,y) TraceFunc_ dummy_____for_trace_func______(x,y)
-
-class TraceFunc_ {
- std::string func_name_;
- public:
- /*
- Calling TraceFunc_ indents the output until the enclosing scope ( {...} )
- is left.
- */
- TraceFunc_(std::string const&);
- TraceFunc_(std::string const&, std::string const& something);
- ~TraceFunc_();
-
- /*
- Creates the trace output file named by filename.
- Must be called before any other tracing function.
- Use the StartTrace macro for it.
- */
- static void StartTrace_(std::string const& filename);
-
- template <class T>
- void Trace_(T const& t) {
- DWORD d;
- std::string indent_s;
- std::stringstream s;
-
- s << t;
-
- for (int i=0; i< indent; i++) indent_s += " ";
-
- ::WriteFile(trace_file_,indent_s.c_str(), indent_s.size(), &d, 0);
- ::WriteFile(trace_file_, s.str().c_str(), s.str().size() ,&d, 0);
- ::WriteFile(trace_file_,"\x0a",1,&d,0);
- }
-
- template <class T, class U>
- void Trace_(T const& t, U const& u) {
- std::string indent_s;
- std::stringstream s;
-
- s << t;
- s << u;
- Trace_(s.str());
- }
-
- static int indent;
- /* trace_file_ is a HANDLE for the file in which the traced output goes.
- The file is opened (that is, created) by calling StartTrace_.
- Better yet, use the StartTrace macro
- to create the file.
- */
- static HANDLE trace_file_;
-};
-
-#else
-
-#define StartTrace(x)
-#define Trace(x)
-#define Trace2(x,y)
-#define TraceFunc(x)
-#define TraceFunc2(x,y)
-
-#endif
-
-#endif // TRACER_H__
+/*
+ Tracer.h
+
+ Copyright (C) 2002-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ The most current version of Tracer.h can be found at
+ http://www.adp-gmbh.ch/cpp/common/Tracer.html
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+#ifndef TRACER_H__
+#define TRACER_H__
+
+#ifdef DO_TRACE
+
+#include <string>
+#include <sstream>
+
+#include <windows.h>
+
+#define StartTrace(x) TraceFunc_::StartTrace_(x)
+#define Trace(x) dummy_____for_trace_func______.Trace_(x)
+#define Trace2(x,y) dummy_____for_trace_func______.Trace_(x,y)
+#define TraceFunc(x) TraceFunc_ dummy_____for_trace_func______(x)
+#define TraceFunc2(x,y) TraceFunc_ dummy_____for_trace_func______(x,y)
+
+class TraceFunc_ {
+ std::string func_name_;
+ public:
+ /*
+ Calling TraceFunc_ indents the output until the enclosing scope ( {...} )
+ is left.
+ */
+ TraceFunc_(std::string const&);
+ TraceFunc_(std::string const&, std::string const& something);
+ ~TraceFunc_();
+
+ /*
+ Creates the trace output file named by filename.
+ Must be called before any other tracing function.
+ Use the StartTrace macro for it.
+ */
+ static void StartTrace_(std::string const& filename);
+
+ template <class T>
+ void Trace_(T const& t) {
+ DWORD d;
+ std::string indent_s;
+ std::stringstream s;
+
+ s << t;
+
+ for (int i=0; i< indent; i++) indent_s += " ";
+
+ ::WriteFile(trace_file_,indent_s.c_str(), indent_s.size(), &d, 0);
+ ::WriteFile(trace_file_, s.str().c_str(), s.str().size() ,&d, 0);
+ ::WriteFile(trace_file_,"\x0a",1,&d,0);
+ }
+
+ template <class T, class U>
+ void Trace_(T const& t, U const& u) {
+ std::string indent_s;
+ std::stringstream s;
+
+ s << t;
+ s << u;
+ Trace_(s.str());
+ }
+
+ static int indent;
+ /* trace_file_ is a HANDLE for the file in which the traced output goes.
+ The file is opened (that is, created) by calling StartTrace_.
+ Better yet, use the StartTrace macro
+ to create the file.
+ */
+ static HANDLE trace_file_;
+};
+
+#else
+
+#define StartTrace(x)
+#define Trace(x)
+#define Trace2(x,y)
+#define TraceFunc(x)
+#define TraceFunc2(x,y)
+
+#endif
+
+#endif // TRACER_H__
diff --git a/WebServer/UrlHelper.h b/WebServer/UrlHelper.h
index 06ab00446..12f12c6fe 100644
--- a/WebServer/UrlHelper.h
+++ b/WebServer/UrlHelper.h
@@ -1,42 +1,42 @@
-/*
- UrlHelper.h
-
- Copyright (C) 2002-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-#ifndef __URL_HELPER_H__
-#define __URL_HELPER_H__
-
-#include <string>
-#include <map>
-
-void SplitUrl (std::string const& url, std::string& protocol, std::string& server, std::string& path);
-bool RemoveProtocolFromUrl(std::string const& url, std::string& protocol, std::string& rest);
-
-void SplitGetReq (std::string et_req, std::string& path, std::map<std::string, std::string>& params);
-
-#endif
+/*
+ UrlHelper.h
+
+ Copyright (C) 2002-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+#ifndef __URL_HELPER_H__
+#define __URL_HELPER_H__
+
+#include <string>
+#include <map>
+
+void SplitUrl (std::string const& url, std::string& protocol, std::string& server, std::string& path);
+bool RemoveProtocolFromUrl(std::string const& url, std::string& protocol, std::string& rest);
+
+void SplitGetReq (std::string et_req, std::string& path, std::map<std::string, std::string>& params);
+
+#endif
diff --git a/WebServer/WebServer.h b/WebServer/WebServer.h
index 044974cb8..882624db5 100644
--- a/WebServer/WebServer.h
+++ b/WebServer/WebServer.h
@@ -1,108 +1,108 @@
-/*
- WebServer.h
-
- Copyright (C) 2003-2004 René Nyffenegger
-
- This source code is provided 'as-is', without any express or implied
- warranty. In no event will the author be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented; you must not
- claim that you wrote the original source code. If you use this source code
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original source code.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-
-*/
-
-/*
- Note on point 2:
- THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
-*/
-
-
-class cEvents;
-class Socket;
-class SocketServer;
-class webserver {
-public:
- struct formdata
- {
- std::string name_;
- std::string filename_;
- std::string content_type_;
- std::string value_;
- };
-
- struct http_request {
-
- http_request()
- : s_( 0 )
- , content_length_( 0 )
- , authentication_given_(false)
- {}
-
- Socket* s_;
- std::string method_;
- std::string path_;
- std::map<std::string, std::string> params_;
- std::map<std::string, std::string> params_post_;
-
- std::string accept_;
- std::string accept_language_;
- std::string accept_encoding_;
- std::string user_agent_;
- int content_length_;
- std::string content_type_;
- std::vector< formdata > multipart_formdata_;
-
- /* status_: used to transmit server's error status, such as
- o 202 OK
- o 404 Not Found
- and so on */
- std::string status_;
-
- /* auth_realm_: allows to set the basic realm for an authentication,
- no need to additionally set status_ if set */
- std::string auth_realm_;
-
- std::string answer_;
-
- /* authentication_given_ is true when the user has entered a username and password.
- These can then be read from username_ and password_ */
- bool authentication_given_;
- std::string username_;
- std::string password_;
- };
-
- typedef void (*request_func) (http_request*);
- webserver(unsigned int port_to_listen, request_func);
- ~webserver();
-
- bool Begin();
- void Stop();
-
-private:
- bool m_bStop;
-
- #ifdef _WIN32
- static unsigned __stdcall Request(void*);
- #else
- static void* Request(void*);
- #endif
-
- static request_func request_func_;
-
- cEvents * m_Events;
- SocketServer* m_Socket;
-};
+/*
+ WebServer.h
+
+ Copyright (C) 2003-2004 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+
+*/
+
+/*
+ Note on point 2:
+ THIS IS NOT THE ORIGINAL SOURCE1!!1!!!~!!~`1ONE!!`1
+*/
+
+
+class cEvents;
+class Socket;
+class SocketServer;
+class webserver {
+public:
+ struct formdata
+ {
+ std::string name_;
+ std::string filename_;
+ std::string content_type_;
+ std::string value_;
+ };
+
+ struct http_request {
+
+ http_request()
+ : s_( 0 )
+ , content_length_( 0 )
+ , authentication_given_(false)
+ {}
+
+ Socket* s_;
+ std::string method_;
+ std::string path_;
+ std::map<std::string, std::string> params_;
+ std::map<std::string, std::string> params_post_;
+
+ std::string accept_;
+ std::string accept_language_;
+ std::string accept_encoding_;
+ std::string user_agent_;
+ int content_length_;
+ std::string content_type_;
+ std::vector< formdata > multipart_formdata_;
+
+ /* status_: used to transmit server's error status, such as
+ o 202 OK
+ o 404 Not Found
+ and so on */
+ std::string status_;
+
+ /* auth_realm_: allows to set the basic realm for an authentication,
+ no need to additionally set status_ if set */
+ std::string auth_realm_;
+
+ std::string answer_;
+
+ /* authentication_given_ is true when the user has entered a username and password.
+ These can then be read from username_ and password_ */
+ bool authentication_given_;
+ std::string username_;
+ std::string password_;
+ };
+
+ typedef void (*request_func) (http_request*);
+ webserver(unsigned int port_to_listen, request_func);
+ ~webserver();
+
+ bool Begin();
+ void Stop();
+
+private:
+ bool m_bStop;
+
+ #ifdef _WIN32
+ static unsigned __stdcall Request(void*);
+ #else
+ static void* Request(void*);
+ #endif
+
+ static request_func request_func_;
+
+ cEvents * m_Events;
+ SocketServer* m_Socket;
+};
diff --git a/WebServer/base64.h b/WebServer/base64.h
index 91b731417..65d5db8b2 100644
--- a/WebServer/base64.h
+++ b/WebServer/base64.h
@@ -1,4 +1,4 @@
-#include <string>
-
-std::string base64_encode(unsigned char const* , unsigned int len);
-std::string base64_decode(std::string const& s);
+#include <string>
+
+std::string base64_encode(unsigned char const* , unsigned int len);
+std::string base64_decode(std::string const& s);