-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuhttps.h
More file actions
80 lines (67 loc) · 2.78 KB
/
uhttps.h
File metadata and controls
80 lines (67 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// --------------------------------------------------------
// uhhtps : a minimal web server which compile under MacOS, Linux and Windows
// by Ph. Jounin September 2025
//
// License: GPLv2
// Module:
// uhttps.h
// --------------------------------------------------------
#define UHTTPS_VERSION "1.0"
#ifndef FALSE
# define FALSE (0==1)
# define TRUE (1==1)
#endif
typedef int BOOL;
// ---------------------------------------------------------
// default parameters
// ---------------------------------------------------------
#define DEFAULT_BURST_PKTS 5
#define DEFAULT_BUFLEN (1448*DEFAULT_BURST_PKTS) // buffer size for reading HTTP command and file content (2 pkts of 1500 bytes)
#define DEFAULT_HTTP_PORT "8080"
#define DEFAULT_TLS_PORT "8443"
#define DEFAULT_MAXTHREADS 1024 // maximum simultaneous connections
#define DEFAULT_HTMLFILE "index.html" // if request is "GET / HTTP/1.1"
#define DEFAULT_AUTO_EXTENSION NULL // try to append an extension if a file name is not found
#define DEFAULT_BINARY_TYPE "application/octet-stream"
#define DEFAULT_TEXT_TYPE "text/plain"
#define DEFAULT_SSL_DIR "."
#define SELECT_TIMEOUT 5 // every 5 seconds, look for terminated threads
#define LISTENING_QUEUE_SIZE 3 // do not need a large queue
// ---------------------------------------------------------
// sSettings is a global variable
// ---------------------------------------------------------
// uhhtps Settings
struct S_Settings
{
// logging
int uVerbose;
int timestamp;
// System
int max_threads; // maximum simultaneous connections
int slow_down; // msec to wait between two frames
// Global Network configuration
BOOL bIPv4;
BOOL bIPv6;
char *szBoundTo;
// http settings
char *szHTTPPort;
// tls settings
BOOL bTLS; /* 0/1: enable TLS */
char *tls_cert; /* PEM cert (fullchain) */
char *tls_key; /* PEM private key */
char *szTlsPort; /* TLS listen port (default 8443) */
char *szOpenSSLDir; /* directory where OpenSSL DLLs are located (Windows only) */
BOOL bRedirectHttp; /* 0/1: 80/8080 -> https:// redirect */
// HTML settings
char *szDirectory;
const char *szDefaultHtmlFile;
const char *szAutoExtension;
const char *szDefaultContentType; // all files accepted with this content-type
};
extern struct S_Settings sSettings;
// ---------------------------------------------------------
// Arduino-like behavior
// ---------------------------------------------------------
int Setup(void);
void doLoop(void);
void Cleanup(void);