UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
webserver.hpp
Go to the documentation of this file.
1#ifndef COMPA_NET_HTTP_WEBSERVER_HPP
2#define COMPA_NET_HTTP_WEBSERVER_HPP
3/**************************************************************************
4 *
5 * Copyright (c) 2000-2003 Intel Corporation
6 * All rights reserved.
7 * Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
8 * Redistribution only with this Copyright remark. Last modified: 2025-05-15
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither name of Intel Corporation nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
30 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 **************************************************************************/
35// Last compare with ./Pupnp source file on 2025-04-10, ver 1.14.20
41#include <miniserver.hpp>
42#include <sock.hpp>
43
48
54 int IsChunkActive; // Chunked encoding should be used. This is only
55 // supported by HTTP 1.1 clients. But I do not support
56 // deprecated HTTP 1.0. This flag is obsolete.
59 char RangeHeader[200];
63
68 const void* CorsHeader;
70 const void* Cookie;
72 const void* RequestCookie;
73 /* Later few more member could be added depending
74 * on the requirement.*/
75};
76
77#if !defined(X_USER_AGENT) || defined(DOXYGEN_RUN)
87#define X_USER_AGENT "redsonic"
88#endif
89
96void web_server_init();
97
110 const char* a_alias_name,
115 const char* a_alias_content,
118 size_t a_alias_content_length,
120 time_t a_last_modified);
121
134 const char* root_dir);
135
144 const char* cors_string);
145
153 http_parser_t* a_parser,
155 http_message_t* a_req,
157 SOCKINFO* a_info);
158
164 MiniServerCallback callback);
165
172void web_server_destroy();
173
174#endif // COMPA_NET_HTTP_WEBSERVER_HPP
Structure of an HTTP parser object.
Structure of an HTTP message.
membuffer gDocumentRootDir
Definition webserver.hpp:45
off_t RangeOffset
member variable
Definition webserver.hpp:61
void web_server_callback(http_parser_t *a_parser, http_message_t *a_req, SOCKINFO *a_info)
Main entry point into web server.
const void * CorsHeader
Definition webserver.hpp:68
long RecvWriteSize
Recv from the network and write into local file.
Definition webserver.hpp:66
int web_server_set_root_dir(const char *root_dir)
Assign the path to the global Document root directory.
off_t ReadSendSize
Read from local source and send on the network.
Definition webserver.hpp:64
const void * RequestCookie
Cookie associated with the request.
Definition webserver.hpp:72
void SetHTTPGetCallback(MiniServerCallback callback)
Set HTTP Get Callback.
int web_server_set_cors(const char *cors_string)
Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameterto the ...
int IsRangeActive
member variable
Definition webserver.hpp:57
int web_server_set_alias(const char *a_alias_name, const char *a_alias_content, size_t a_alias_content_length, time_t a_last_modified)
Replaces current alias with the given alias.
void web_server_destroy()
Release memory allocated for the global web server root directory and the global XML document.
const void * Cookie
Cookie associated with the virtualDir.
Definition webserver.hpp:70
char AcceptLanguageHeader[200]
member variable
Definition webserver.hpp:60
int IsTrailers
member variable
Definition webserver.hpp:58
void web_server_init()
Initilialize root directory for web server and different documents.
membuffer gWebserverCorsString
Definition webserver.hpp:47
int IsVirtualFile
member variable
Definition webserver.hpp:53
char RangeHeader[200]
member variable
Definition webserver.hpp:59
int IsChunkActive
member variable
Definition webserver.hpp:54
Send instruction.
Definition webserver.hpp:50
Maintains a block of dynamically allocated memory.
Definition membuffer.hpp:61
Manage "Step 0: Addressing" of the UPnP+™ specification.
void(* MiniServerCallback)(http_parser_t *parser, http_message_t *request, SOCKINFO *info)
For a miniserver callback function.
Manage network sockets and connections.
Additional socket information for connections and ssl.
Definition sock.hpp:65