ESP32 HTTPS Server

HTTPSServerConstants.hpp
1 #ifndef SRC_HTTPSSERVERCONSTANTS_HPP_
2 #define SRC_HTTPSSERVERCONSTANTS_HPP_
3
4 #include "Arduino.h"
5
6 // 1: Error
7 // 2: Error + Warn
8 // 3: Error + Warn + Info
9 // 4: Error + Warn + Info + Debug
10
11 #ifndef HTTPS_LOGLEVEL
12 #define HTTPS_LOGLEVEL 3
13 #endif
14
15 #ifdef HTTPS_LOGTIMESTAMP
16 #define HTTPS_LOGTAG(LVL) Serial.printf("[HTTPS:" LVL ":%10lu] ", millis())
17 #else
18 #define HTTPS_LOGTAG(LVL) Serial.print("[HTTPS:" LVL "] ")
19 #endif
20
21 #if HTTPS_LOGLEVEL > 0
22 #define HTTPS_LOGE(...) HTTPS_LOGTAG("E");Serial.printf(__VA_ARGS__);Serial.println()
23 #else
24 #define HTTPS_LOGE(...) do {} while (0)
25 #endif
26
27 #if HTTPS_LOGLEVEL > 1
28 #define HTTPS_LOGW(...) HTTPS_LOGTAG("W");Serial.printf(__VA_ARGS__);Serial.println()
29 #else
30 #define HTTPS_LOGW(...) do {} while (0)
31 #endif
32
33 #if HTTPS_LOGLEVEL > 2
34 #define HTTPS_LOGI(...) HTTPS_LOGTAG("I");Serial.printf(__VA_ARGS__);Serial.println()
35 #else
36 #define HTTPS_LOGI(...) do {} while (0)
37 #endif
38
39 #if HTTPS_LOGLEVEL > 3
40 #define HTTPS_LOGD(...) HTTPS_LOGTAG("D");Serial.printf(__VA_ARGS__);Serial.println()
41 #else
42 #define HTTPS_LOGD(...) do {} while (0)
43 #endif
44
45 // The following lines define limits of the protocol. Exceeding these limits will lead to a 500 error
46
47 // Maximum of header lines that are parsed
48 #ifndef HTTPS_REQUEST_MAX_HEADERS
49 #define HTTPS_REQUEST_MAX_HEADERS 20
50 #endif
51
52 // Maximum length of the request line (GET /... HTTP/1.1)
53 #ifndef HTTPS_REQUEST_MAX_REQUEST_LENGTH
54 #define HTTPS_REQUEST_MAX_REQUEST_LENGTH 128
55 #endif
56
57 // Maximum length of a header line (including name and value)
58 #ifndef HTTPS_REQUEST_MAX_HEADER_LENGTH
59 #define HTTPS_REQUEST_MAX_HEADER_LENGTH 384
60 #endif
61
62 // Chunk size used for reading data from the ssl-enabled socket
63 #ifndef HTTPS_CONNECTION_DATA_CHUNK_SIZE
64 #define HTTPS_CONNECTION_DATA_CHUNK_SIZE 512
65 #endif
66
67 // Size (in bytes) of the Connection:keep-alive Cache (we need to be able to
68 // store-and-forward the response to calculate the content-size)
69 #ifndef HTTPS_KEEPALIVE_CACHESIZE
70 #define HTTPS_KEEPALIVE_CACHESIZE 1400
71 #endif
72
73 // Timeout for an HTTPS connection without any transmission
74 #ifndef HTTPS_CONNECTION_TIMEOUT
75 #define HTTPS_CONNECTION_TIMEOUT 20000
76 #endif
77
78 // Timeout used to wait for shutdown of SSL connection (ms)
79 // (time for the client to return notify close flag) - without it, truncation attacks might be possible
80 #ifndef HTTPS_SHUTDOWN_TIMEOUT
81 #define HTTPS_SHUTDOWN_TIMEOUT 5000
82 #endif
83
84 // Length of a SHA1 hash
85 #ifndef HTTPS_SHA1_LENGTH
86 #define HTTPS_SHA1_LENGTH 20
87 #endif
88
89 #endif /* SRC_HTTPSSERVERCONSTANTS_HPP_ */