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