Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / lib / libUPnP / Platinum / Source / Core / PltHttpServer.h
blob04c47fce03b58797d54f775de8e9e16797cf829e
1 /*****************************************************************
3 | Platinum - HTTP Server
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
33 ****************************************************************/
35 /** @file
36 HTTP Server
39 #ifndef _PLT_HTTP_SERVER_H_
40 #define _PLT_HTTP_SERVER_H_
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 #include "PltHttpServerTask.h"
48 /*----------------------------------------------------------------------
49 | PLT_HttpServer class
50 +---------------------------------------------------------------------*/
51 /**
52 The PLT_HttpServer class provides an asynchronous way to handle multiple HTTP requests
53 concurrently. Pipelining requests and keep-alive connections are supported.
55 class PLT_HttpServer : public NPT_HttpRequestHandler,
56 public NPT_HttpServer
58 public:
59 PLT_HttpServer(NPT_IpAddress address = NPT_IpAddress::Any,
60 NPT_IpPort port = 0,
61 bool allow_random_port_on_bind_failure = false,
62 NPT_Cardinal max_clients = 50,
63 bool reuse_address = false);
64 ~PLT_HttpServer() override;
66 // class methods
67 static NPT_Result ServeFile(const NPT_HttpRequest& request,
68 const NPT_HttpRequestContext& context,
69 NPT_HttpResponse& response,
70 NPT_String file_path);
71 static NPT_Result ServeStream(const NPT_HttpRequest& request,
72 const NPT_HttpRequestContext& context,
73 NPT_HttpResponse& response,
74 NPT_InputStreamReference& stream,
75 const char* content_type);
77 // NPT_HttpRequestHandler methods
78 NPT_Result SetupResponse(NPT_HttpRequest& request,
79 const NPT_HttpRequestContext& context,
80 NPT_HttpResponse& response) override;
82 // methods
83 virtual NPT_Result Start();
84 virtual NPT_Result Stop();
85 virtual unsigned int GetPort() { return m_Port; }
87 private:
88 PLT_TaskManagerReference m_TaskManager;
89 NPT_Reference<NPT_HttpServer> m_Server;
90 NPT_IpAddress m_Address;
91 NPT_IpPort m_Port;
92 bool m_AllowRandomPortOnBindFailure;
93 bool m_ReuseAddress;
94 bool m_Running;
95 bool m_Aborted;
98 typedef NPT_Reference<PLT_HttpServer> PLT_HttpServerReference;
100 #endif /* _PLT_HTTP_SERVER_H_ */