Skip to content

Commit 1c0608d

Browse files
AndreyDodonov-EHdanieldegrasse
authored andcommitted
net: http: service: check for uncompressed file correctly
Correct not resetting compression extension, when checking for an uncompressed file, in case if compression is enabled, but no compressed file found. Signed-off-by: Andrey Dodonov <[email protected]>
1 parent cae12e6 commit 1c0608d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

subsys/net/lib/http/http_server_core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,11 +800,10 @@ int http_server_find_file(char *fname, size_t fname_size, size_t *file_size,
800800
uint8_t supported_compression, enum http_compression *chosen_compression)
801801
{
802802
struct fs_dirent dirent;
803-
size_t len;
804803
int ret;
805804

806-
len = strlen(fname);
807805
if (IS_ENABLED(CONFIG_HTTP_SERVER_COMPRESSION)) {
806+
const size_t len = strlen(fname);
808807
*chosen_compression = HTTP_NONE;
809808
if (IS_BIT_SET(supported_compression, HTTP_BR)) {
810809
snprintk(fname + len, fname_size - len, ".br");
@@ -846,6 +845,8 @@ int http_server_find_file(char *fname, size_t fname_size, size_t *file_size,
846845
goto return_filename;
847846
}
848847
}
848+
/* No compressed file found, try the original filename */
849+
fname[len] = '\0';
849850
}
850851
ret = fs_stat(fname, &dirent);
851852
if (ret != 0) {

0 commit comments

Comments
 (0)