http_server_misc.h
Go to the documentation of this file.
1 /**
2  * @file http_server_misc.h
3  * @brief HTTP server (miscellaneous functions)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _HTTP_SERVER_MISC_H
32 #define _HTTP_SERVER_MISC_H
33 
34 //Dependencies
35 #include "http/http_server.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 //HTTP server related functions
44 error_t httpParseRequestLine(HttpConnection *connection, char_t *requestLine);
45 
47  char_t *buffer, size_t size, char_t *firstChar);
48 
49 void httpParseHeaderField(HttpConnection *connection,
50  const char_t *name, char_t *value);
51 
53  char_t *value);
54 
56  char_t *value);
57 
59  char_t *value);
60 
62 
64 
65 void httpInitResponseHeader(HttpConnection *connection);
67 
68 error_t httpSend(HttpConnection *connection,
69  const void *data, size_t length, uint_t flags);
70 
72  void *data, size_t size, size_t *received, uint_t flags);
73 
74 void httpGetAbsolutePath(HttpConnection *connection,
75  const char_t *relative, char_t *absolute, size_t maxLen);
76 
77 bool_t httpCompExtension(const char_t *filename, const char_t *extension);
78 
80  char_t *output, size_t outputSize);
81 
82 void httpConvertArrayToHexString(const uint8_t *input,
83  size_t inputLen, char_t *output);
84 
85 //C++ guard
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif
error_t httpFormatResponseHeader(HttpConnection *connection, char_t *buffer)
Format HTTP response header.
int bool_t
Definition: compiler_port.h:53
HTTP server (HyperText Transfer Protocol)
bool_t httpCompExtension(const char_t *filename, const char_t *extension)
Compare filename extension.
error_t httpSend(HttpConnection *connection, const void *data, size_t length, uint_t flags)
Send data to the client.
uint8_t data[]
Definition: ethernet.h:222
void httpParseConnectionField(HttpConnection *connection, char_t *value)
Parse Connection header field.
error_t httpParseRequestLine(HttpConnection *connection, char_t *requestLine)
Parse Request-Line.
char_t name[]
void httpInitResponseHeader(HttpConnection *connection)
Initialize response header.
void httpParseContentTypeField(HttpConnection *connection, char_t *value)
Parse Content-Type header field.
void httpConvertArrayToHexString(const uint8_t *input, size_t inputLen, char_t *output)
Convert byte array to hex string.
error_t
Error codes.
Definition: error.h:43
error_t httpReadRequestHeader(HttpConnection *connection)
Read HTTP request header and parse its contents.
#define HttpConnection
Definition: http_server.h:332
char_t filename[]
Definition: tftp_common.h:93
void httpParseCookieField(HttpConnection *connection, char_t *value)
Parse Cookie header field.
void httpParseHeaderField(HttpConnection *connection, const char_t *name, char_t *value)
Parse HTTP header field.
uint8_t length
Definition: tcp.h:368
uint8_t flags
Definition: tcp.h:351
char char_t
Definition: compiler_port.h:48
void httpParseAcceptEncodingField(HttpConnection *connection, char_t *value)
Parse Accept-Encoding header field.
error_t httpReadChunkSize(HttpConnection *connection)
Read chunk-size field from the input stream.
error_t httpReadHeaderField(HttpConnection *connection, char_t *buffer, size_t size, char_t *firstChar)
Read multiple-line header field.
uint8_t value[]
Definition: tcp.h:369
error_t httpReceive(HttpConnection *connection, void *data, size_t size, size_t *received, uint_t flags)
Receive data from the client.
void httpGetAbsolutePath(HttpConnection *connection, const char_t *relative, char_t *absolute, size_t maxLen)
Retrieve the full pathname to the specified resource.
unsigned int uint_t
Definition: compiler_port.h:50
error_t httpDecodePercentEncodedString(const char_t *input, char_t *output, size_t outputSize)
Decode a percent-encoded string.