File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
doc/connectivity/networking/api Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,10 @@ content type text/html.
261
261
262
262
HTTP_SERVER_CONTENT_TYPE(json, "application/json")
263
263
264
+ When serving files from a static filesystem, the response chunk size can be configured
265
+ using the :kconfig:option: `CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE ` Kconfig option.
266
+ This determines the size of individual chunks when transmitting file content to clients.
267
+
264
268
Dynamic resources
265
269
=================
266
270
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ if HTTP_SERVER
44
44
45
45
config HTTP_SERVER_STACK_SIZE
46
46
int "HTTP server thread stack size"
47
+ default 4096 if FILE_SYSTEM
47
48
default 3072
48
49
help
49
50
HTTP server thread stack size for processing RX/TX events.
@@ -219,6 +220,17 @@ config HTTP_SERVER_COMPRESSION
219
220
5. deflate -> .zz
220
221
6. File without compression
221
222
223
+ config 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
+
222
234
endif
223
235
224
236
# Hidden option to avoid having multiple individual options that are ORed together
Original file line number Diff line number Diff line change @@ -482,11 +482,19 @@ int handle_http1_static_fs_resource(struct http_resource_detail_static_fs *stati
482
482
sizeof("Content-Length: 01234567890123456789\r\n")
483
483
#define CONTENT_ENCODING_HEADER_SIZE \
484
484
sizeof(CONTENT_ENCODING_HEADER) + HTTP_COMPRESSION_MAX_STRING_LEN + sizeof("\r\n")
485
+ /* Calculate the minimum size required for the headers */
485
486
#define STATIC_FS_RESPONSE_SIZE \
486
487
COND_CODE_1( \
487
488
IS_ENABLED(CONFIG_HTTP_SERVER_COMPRESSION), \
488
489
(STATIC_FS_RESPONSE_BASE_SIZE + CONTENT_ENCODING_HEADER_SIZE), \
489
490
(STATIC_FS_RESPONSE_BASE_SIZE))
491
+ #if CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE > 0
492
+ BUILD_ASSERT (CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE >= STATIC_FS_RESPONSE_SIZE ,
493
+ "CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE must be at least "
494
+ "large enough to hold HTTP headers" );
495
+ #undef STATIC_FS_RESPONSE_SIZE
496
+ #define STATIC_FS_RESPONSE_SIZE CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE
497
+ #endif
490
498
491
499
enum http_compression chosen_compression = 0 ;
492
500
int len ;
You can’t perform that action at this time.
0 commit comments