@@ -482,12 +482,23 @@ 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
+
486
+ /* Calculate the minimum required size */
485
487
#define STATIC_FS_RESPONSE_SIZE \
486
488
COND_CODE_1( \
487
489
IS_ENABLED(CONFIG_HTTP_SERVER_COMPRESSION), \
488
490
(STATIC_FS_RESPONSE_BASE_SIZE + CONTENT_ENCODING_HEADER_SIZE), \
489
491
(STATIC_FS_RESPONSE_BASE_SIZE))
490
492
493
+ // Issue in Zephyr: https://github.com/zephyrproject-rtos/zephyr/issues/92921
494
+ #if CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE > 0
495
+ BUILD_ASSERT (CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE >= STATIC_FS_RESPONSE_SIZE ,
496
+ "CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE must be at least "
497
+ "large enough to hold HTTP headers" );
498
+ #undef STATIC_FS_RESPONSE_SIZE
499
+ #define STATIC_FS_RESPONSE_SIZE CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE
500
+ #endif
501
+
491
502
enum http_compression chosen_compression = 0 ;
492
503
int len ;
493
504
int remaining ;
@@ -554,18 +565,15 @@ int handle_http1_static_fs_resource(struct http_resource_detail_static_fs *stati
554
565
client -> http1_headers_sent = true;
555
566
556
567
/* read and send file */
557
- // Issue in Zephyr: https://github.com/zephyrproject-rtos/zephyr/issues/92921
558
- char body_response [2036 ];
559
- LOG_WRN ("STATIC_FS_RESPONSE_SIZE=%d" , STATIC_FS_RESPONSE_SIZE );
560
568
remaining = file_size ;
561
569
while (remaining > 0 ) {
562
- len = fs_read (& file , body_response , sizeof (body_response ));
570
+ len = fs_read (& file , http_response , sizeof (http_response ));
563
571
if (len < 0 ) {
564
572
LOG_ERR ("Filesystem read error (%d)" , len );
565
573
goto close ;
566
574
}
567
575
568
- ret = http_server_sendall (client , body_response , len );
576
+ ret = http_server_sendall (client , http_response , len );
569
577
if (ret < 0 ) {
570
578
goto close ;
571
579
}
0 commit comments