Commit 1c0608dc authored by Andrey Dodonov's avatar Andrey Dodonov Committed by Daniel DeGrasse
Browse files

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: default avatarAndrey Dodonov <Andrey.Dodonov@endress.com>
parent cae12e6d
Loading
Loading
Loading
Loading
+3 −2
Changes for subsys/net/lib/http/http_server_core.c: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -800,11 +800,10 @@ int http_server_find_file(char *fname, size_t fname_size, size_t *file_size,
			  uint8_t supported_compression, enum http_compression *chosen_compression)
{
	struct fs_dirent dirent;
	size_t len;
	int ret;

	len = strlen(fname);
	if (IS_ENABLED(CONFIG_HTTP_SERVER_COMPRESSION)) {
		const size_t len = strlen(fname);
		*chosen_compression = HTTP_NONE;
		if (IS_BIT_SET(supported_compression, HTTP_BR)) {
			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,
				goto return_filename;
			}
		}
		/* No compressed file found, try the original filename */
		fname[len] = '\0';
	}
	ret = fs_stat(fname, &dirent);
	if (ret != 0) {