kodi
PltHttpServer.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Platinum - HTTP Server
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
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.
13 |
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
21 |
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.
26 |
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
32 |
33 ****************************************************************/
34 
39 #ifndef _PLT_HTTP_SERVER_H_
40 #define _PLT_HTTP_SERVER_H_
41 
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 #include "PltHttpServerTask.h"
47 
48 /*----------------------------------------------------------------------
49 | PLT_HttpServer class
50 +---------------------------------------------------------------------*/
56  public NPT_HttpServer
57 {
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;
65 
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);
76 
77  // NPT_HttpRequestHandler methods
78  NPT_Result SetupResponse(NPT_HttpRequest& request,
79  const NPT_HttpRequestContext& context,
80  NPT_HttpResponse& response) override;
81 
82  // methods
83  virtual NPT_Result Start();
84  virtual NPT_Result Stop();
85  virtual unsigned int GetPort() { return m_Port; }
86 
87 private:
88  PLT_TaskManagerReference m_TaskManager;
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;
96 };
97 
99 
100 #endif /* _PLT_HTTP_SERVER_H_ */
Definition: NptHttp.h:566
The PLT_HttpServer class provides an asynchronous way to handle multiple HTTP requests concurrently...
Definition: PltHttpServer.h:55
Definition: NptHttp.h:315
Definition: NptHttp.h:282
Definition: NptHttp.h:593
Definition: NptNetwork.h:74
HTTP Server Tasks.
Definition: NptStrings.h:57
Definition: NptHttp.h:705