1# Copyright (c) 2016 Intel Corporation
2# SPDX-License-Identifier: Apache-2.0
3
4config HTTP_PARSER
5	bool "HTTP Parser support"
6	select HTTP_PARSER_URL
7	help
8	  This option enables the http_parser library from nodejs.
9	  This parser requires some string-related routines commonly
10	  provided by a libc implementation.
11
12config HTTP_PARSER_URL
13	bool "HTTP Parser for URL support"
14	help
15	  This option enables the URI parser library based on source from nodejs.
16	  This parser requires some string-related routines commonly
17	  provided by a libc implementation.
18
19config HTTP_PARSER_STRICT
20	bool "HTTP strict parsing"
21	depends on (HTTP_PARSER || HTTP_PARSER_URL)
22	help
23	  This option enables the strict parsing option
24
25config HTTP_CLIENT
26	bool "HTTP client API"
27	select HTTP_PARSER
28	select HTTP_PARSER_URL
29	help
30	  HTTP client API
31
32menuconfig HTTP_SERVER
33	bool "HTTP Server [EXPERIMENTAL]"
34	select HTTP_PARSER
35	select HTTP_PARSER_URL
36	select EXPERIMENTAL
37	select NET_SOCKETS
38	select ZVFS
39	select ZVFS_EVENTFD
40	imply NET_IPV4_MAPPING_TO_IPV6 if NET_IPV4 && NET_IPV6
41	help
42	  HTTP1 and HTTP2 server support.
43
44if HTTP_SERVER
45
46config HTTP_SERVER_STACK_SIZE
47	int "HTTP server thread stack size"
48	default 4096 if FILE_SYSTEM
49	default 3072
50	help
51	  HTTP server thread stack size for processing RX/TX events.
52
53config HTTP_SERVER_NUM_SERVICES
54	int "Number of HTTP Server Instances"
55	default 1
56	range 1 100
57	help
58	  This setting determines the number of http services that the server supports.
59
60config HTTP_SERVER_MAX_CLIENTS
61	int "Max number of HTTP/2 clients"
62	default 3
63	range 1 100
64	help
65	  This setting determines the maximum number of HTTP/2 clients that the server can handle at once.
66
67config HTTP_SERVER_MAX_STREAMS
68	int "Max number of HTTP/2 streams"
69	default 10
70	range 1 100
71	help
72	  This setting determines the maximum number of HTTP/2 streams for each client.
73
74config HTTP_SERVER_CLIENT_BUFFER_SIZE
75	int "Client Buffer Size"
76	default 256
77	range 64 $(UINT32_MAX)
78	help
79	  This setting determines the buffer size for each client.
80
81config HTTP_SERVER_HUFFMAN_DECODE_BUFFER_SIZE
82	int "Size of the buffer used for decoding Huffman-encoded strings"
83	default 256
84	range 64 $(UINT32_MAX)
85	help
86	  Size of the buffer used for decoding Huffman-encoded strings when
87	  processing HPACK compressed headers. This effectively limits the
88	  maximum length of an individual HTTP header supported.
89
90config HTTP_SERVER_MAX_URL_LENGTH
91	int "Maximum HTTP URL Length"
92	default 256
93	range 32 2048
94	help
95	  This setting determines the maximum length of the HTTP URL that the server can process.
96
97config HTTP_SERVER_MAX_CONTENT_TYPE_LENGTH
98	int "Maximum HTTP Content-Type Length"
99	default 64
100	range 1 128
101	help
102	  This setting determines the maximum length of the HTTP Content-Length field.
103
104config HTTP_SERVER_MAX_HEADER_LEN
105	int "Maximum HTTP Header Field/Value Length"
106	default 32
107	range 32 512
108	help
109	  This setting determines the maximum length of HTTP header field or value
110	  that can be parsed. The default value is sufficient for HTTP server
111	  internal header processing, and only needs to be increased if the
112	  application wishes to access headers of a greater length.
113
114config HTTP_SERVER_HTTP2_MAX_HEADER_FRAME_LEN
115	int "Maximum HTTP/2 response header frame length"
116	default 64
117	range 64 2048
118	help
119	  This setting determines the maximum length of an HTTP/2 header frame
120	  (applies to response headers only, not request headers). The default
121	  value is sufficient for the standard headers included with a response,
122	  and only needs to be increased if the application wishes to send
123	  additional response headers.
124
125config HTTP_SERVER_CAPTURE_HEADERS
126	bool "Allow capturing HTTP headers for application use"
127	help
128	  This setting enables the HTTP server to capture selected headers that have
129	  been registered by the application.
130
131config HTTP_SERVER_CAPTURE_HEADER_BUFFER_SIZE
132	int "Size of buffer for capturing HTTP headers for application use"
133	default 128
134	range 32 2048
135	depends on HTTP_SERVER_CAPTURE_HEADERS
136	help
137	  This setting determines the size of the (per-client) buffer used to store
138	  HTTP headers for later use by the application.
139
140config HTTP_SERVER_CAPTURE_HEADER_COUNT
141	int "Maximum number of HTTP headers to be captured for application use"
142	default 3
143	range 1 100
144	depends on HTTP_SERVER_CAPTURE_HEADERS
145	help
146	  This setting determines the maximum number of HTTP headers it is possible
147	  to capture for application use in a single HTTP request.
148
149config HTTP_SERVER_CLIENT_INACTIVITY_TIMEOUT
150	int "Client inactivity timeout (seconds)"
151	default 10
152	range 1 86400
153	help
154	  This timeout specifies maximum time the client may remain inactive
155	  (i. e. not sending or receiving any data) before the server drops the
156	  connection.
157
158config HTTP_SERVER_WEBSOCKET
159	bool "Allow upgrading to Websocket connection"
160	select WEBSOCKET_CLIENT
161	select WEBSOCKET
162	help
163	  If this is enabled, then the user can allow the HTTP connection to be
164	  upgraded to a Websocket connection. The user can then define a Websocket
165	  handler that is called after upgrading to handle the Websocket network
166	  traffic.
167
168config HTTP_SERVER_RESOURCE_WILDCARD
169	bool "Allow wildcard matching of resources"
170	# The POSIX_C_LIB_EXT will get fnmatch() support
171	select POSIX_C_LIB_EXT
172	help
173	  Allow user to specify wildcards when setting up resource strings.
174	  This means that instead of specifying multiple resources with exact
175	  string matches, one resource handler could handle multiple URLs.
176
177config HTTP_SERVER_RESTART_DELAY
178	int "Delay before re-initialization when restarting server"
179	default 1000
180	range 1 60000
181	help
182	  In case server restarts for any reason, the server re-initialization
183	  will be delayed by this value (milliseconds). The delay is needed to
184	  allow any existing connections to finalize to avoid binding errors
185	  during initialization.
186
187config HTTP_SERVER_TLS_USE_ALPN
188	bool "ALPN support for HTTPS server"
189	depends on NET_SOCKETS_SOCKOPT_TLS
190	depends on MBEDTLS_SSL_ALPN
191	help
192	  Use ALPN (application layer protocol negotiation) to negotiate HTTP2
193	  protocol for TLS connections. Web browsers use this mechanism to determine
194	  whether HTTP2 is supported.
195
196config HTTP_SERVER_REPORT_FAILURE_REASON
197	bool "Report failure reason in HTTP 500 Internal Server Error reply"
198	help
199	  If enabled, the server will include the failure reason within
200	  HTTP 500 Internal Server Error response. Otherwise, no information
201	  is provided within the message.
202
203config WEBSOCKET_CONSOLE
204	bool
205	default y if HTTP_SERVER_WEBSOCKET && SHELL_BACKEND_WEBSOCKET
206	help
207	  Hidden option that is enabled only when all the necessary options
208	  needed by websocket console are set.
209
210config HTTP_SERVER_COMPRESSION
211	bool "Compression support in HTTP fileserver"
212	help
213	  If enabled, the fileserver will parse the accept-encoding header
214	  from the client and extract the supported compression methods.
215	  Afterwards it will try to serve the first compressed file available
216	  by using the file ending as compression indicator in this order:
217	    1. brotli   -> .br
218	    2. gzip     -> .gz
219	    3. zstd     -> .zst
220	    4. compress -> .lzw
221	    5. deflate  -> .zz
222	    6. File without compression
223
224config HTTP_SERVER_STATIC_FS_RESPONSE_SIZE
225	int "Size of static file system response buffer"
226	depends on FILE_SYSTEM
227	default 1024
228	help
229	  The size of a single chunk when serving static files from the file system.
230	  This config value must be large enough to hold the headers in a single chunk.
231	  If set to 0, the server will use the minimal viable buffer size for the response.
232	  Please note that it is allocated on the stack of the HTTP server thread,
233	  so CONFIG_HTTP_SERVER_STACK_SIZE has to be sufficiently large.
234
235config HTTP_SERVER_COMPLETE_STATUS_PHRASES
236	bool "Complete HTTP status reason phrases"
237	help
238	  Include reason phrases for HTTP status codes in server responses.
239	  When disabled, HTTP responses will not include reason phrases,
240	  reducing code size. Note that reason phrases are optional per
241	  HTTP specification and their absence does not affect protocol
242	  compliance or client behavior.
243
244endif
245
246# Hidden option to avoid having multiple individual options that are ORed together
247config HTTP
248	bool
249	depends on (HTTP_PARSER_URL || HTTP_PARSER || HTTP_CLIENT || HTTP_SERVER)
250	default y
251
252module = NET_HTTP
253module-dep = NET_LOG
254module-str = Log level for HTTP client library
255module-help = Enables HTTP client code to output debug messages.
256source "subsys/net/Kconfig.template.log_config.net"
257
258module = NET_HTTP_SERVER
259module-dep = NET_LOG
260module-str = Log level for HTTP server library
261module-help = Enables HTTP server code to output debug messages.
262source "subsys/net/Kconfig.template.log_config.net"
263