Embedded TCP/IP stack  4.7.0
fnet_http_srv.h
1 /**************************************************************************
2 *
3 * Copyright 2008-2018 by Andrey Butok. FNET Community.
4 *
5 ***************************************************************************
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ***************************************************************************
20 *
21 * FNET HTTP Server API.
22 *
23 ***************************************************************************/
24 
25 #ifndef _FNET_HTTP_SRV_H_
26 
27 #define _FNET_HTTP_SRV_H_
28 
29 #if FNET_CFG_HTTP_SRV || defined(__DOXYGEN__)
30 
66 #include "fnet_http_srv_auth.h"
67 
68 /**************************************************************************/
72 #if FNET_CFG_HTTP_SRV_VERSION_MAJOR /*HTTP/1.x*/
73  #define FNET_HTTP_SRV_VERSION_MAJOR (1u)
74 #else /*HTTP/0.9*/
75  #define FNET_HTTP_SRV_VERSION_MAJOR (0u)
76 #endif
77 
78 /**************************************************************************/
82 #if FNET_CFG_HTTP_SRV_VERSION_MAJOR /* HTTP/1.x*/
83  #define FNET_HTTP_SRV_VERSION_MINOR (0u)
84 #else /*HTTP/0.9*/
85  #define FNET_HTTP_SRV_VERSION_MINOR (9u)
86 #endif
87 
88 
89 #if FNET_CFG_HTTP_SRV_VERSION_MAJOR /* HTTP/1.x*/ || defined(__DOXYGEN__)
90 
91 /********************************************************************/
99 typedef enum
100 {
163 #endif
164 
165 #if (FNET_CFG_HTTP_SRV_TLS && FNET_CFG_TLS) || defined(__DOXYGEN__)
166 /**************************************************************************/
169 typedef struct
170 {
171  const fnet_uint8_t *certificate_buffer;
173  const fnet_uint8_t *private_key_buffer;
176 #endif
177 
178 /**************************************************************************/
182 typedef fnet_int32_t fnet_http_srv_desc_t;
183 
184 /**************************************************************************/
188 typedef fnet_int32_t fnet_http_srv_session_t;
189 
190 #include "fnet_http_srv_ssi.h"
191 #include "fnet_http_srv_cgi.h"
192 #include "fnet_http_srv_post.h"
193 
194 /**************************************************************************/
197 typedef struct
198 {
202  struct fnet_sockaddr address;
206 #if FNET_CFG_HTTP_SRV_SSI || defined(__DOXYGEN__)
208 #endif
209 #if FNET_CFG_HTTP_SRV_CGI || defined(__DOXYGEN__)
211 #endif
212 #if (FNET_CFG_HTTP_SRV_AUTHENTICATION_BASIC && FNET_CFG_HTTP_SRV_VERSION_MAJOR) || defined(__DOXYGEN__)
214 #endif
215 #if (FNET_CFG_HTTP_SRV_POST && FNET_CFG_HTTP_SRV_VERSION_MAJOR) || defined(__DOXYGEN__)
217 #endif
218 #if (FNET_CFG_HTTP_SRV_TLS && FNET_CFG_TLS) || defined(__DOXYGEN__)
220 #endif
222 
223 #if defined(__cplusplus)
224 extern "C" {
225 #endif
226 
227 /***************************************************************************/
248 
249 /***************************************************************************/
266 
267 /***************************************************************************/
283 
284 /***************************************************************************/
308 void fnet_http_srv_query_unencode(fnet_uint8_t *dest, fnet_uint8_t *src);
309 
310 #if FNET_CFG_HTTP_SRV_VERSION_MAJOR /* HTTP/1.x*/ || defined(__DOXYGEN__)
311 
312 /**************************************************************************/
323 
324 /**************************************************************************/
335 
336 /**************************************************************************/
347 
348 #endif
349 
350 #if defined(__cplusplus)
351 }
352 #endif
353 
356 #endif /* FNET_CFG_HTTP_SRV */
357 
358 #endif
void fnet_http_srv_query_unencode(fnet_uint8_t *dest, fnet_uint8_t *src)
Converts escaped string to an original format.
Bad Gateway. The server, while acting as a gateway or proxy, received an invalid response from the u...
Input parameters for fnet_http_srv_init().
const fnet_uint8_t * private_key_buffer
Buffer holding the private key in PEM or DER format.
POST-method callback function table.
void fnet_http_srv_release(fnet_http_srv_desc_t desc)
Releases the HTTP Server service.
const fnet_http_srv_cgi_t * cgi_table
Pointer to the optional CGI callback function table.
Not Modified. If the client has performed a conditional GET request and access is allowed...
Created. The request has been fulfilled and resulted in a new resource being created.
const fnet_uint8_t * certificate_buffer
Buffer holding the certificate data in PEM or DER format.
Not Found. The server has not found anything matching the Request-URI.
fnet_bool_t fnet_http_srv_is_enabled(fnet_http_srv_desc_t desc)
Detects if the HTTP Server service is enabled or disabled.
const fnet_http_srv_post_t * post_table
Pointer to the optional POST callback function table.
OK. The request has succeeded.
CGI callback function table.
fnet_int32_t fnet_http_srv_desc_t
HTTP server descriptor.
No Content. The server has fulfilled the request but there is no new information to send back...
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:55
fnet_int32_t fnet_http_srv_session_t
HTTP session handle.
void fnet_http_srv_set_response_content_length(fnet_http_srv_session_t session, fnet_size_t content_length)
Sets content length in HTTP response header.
HTTP Authentication table.
fnet_char_t * index_path
Index file path (null-terminated string). It's relative to the root_path.
Bad Request. The request could not be understood by the server due to malformed syntax.
const fnet_http_srv_auth_t * auth_table
Pointer to the optional HTTP Access Authentification table.
Moved Temporarily. The requested resource resides temporarily under a different URL. It's not supported by the FNET HTTP Server.
NONE. Status code is not defined.
Internal Server Error. The server encountered an unexpected condition which prevented it from fulfil...
fnet_bool_t
Boolean type.
Definition: fnet_stdlib.h:80
const fnet_http_srv_ssi_t * ssi_table
Pointer to the optional SSI callback function table.
fnet_size_t private_key_buffer_size
Size of the private key buffer (including the terminating null byte for PEM data).
Not Implemented. The server does not support the functionality required to fulfill the request...
fnet_char_t * root_path
Server root-directory path (null-terminated string).
Unauthorized. The request requires user authentication.
SSI callback function table.
fnet_http_srv_desc_t fnet_http_srv_init(fnet_http_srv_params_t *params)
Initializes the HTTP Server service.
Service Unavailable. The server is currently unable to handle the request due to a temporary overloa...
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:75
void fnet_http_srv_set_response_no_header(fnet_http_srv_session_t session)
Disables sending of HTTP response status-code and header.
fnet_http_srv_tls_params_t * tls_params
Pointer to the optional HTTP over TLS (HTTPS) parameters.
fnet_size_t certificate_buffer_size
Size of the certificate buffer (including the terminating null byte for PEM data).
fnet_http_srv_status_code_t
HTTP/1.0 Status-Code definitions according to RFC1945.
Definition: fnet_http_srv.h:99
void fnet_http_srv_set_response_status_code(fnet_http_srv_session_t session, fnet_http_srv_status_code_t status_code)
Sets status code in HTTP response status-line.
Forbidden. The server understood the request, but is refusing to fulfill it.
Moved Permanently. The requested resource has been assigned a new permanent URL and any future refer...
Accepted. The request has been accepted for processing, but the processing has not been completed...
Socket address structure.
Definition: fnet_socket.h:268
HTTP over TLS (HTTPS) input parameters for fnet_http_srv_init().

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net