mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Update makefsdata.py to support content encoding Fixes #2548 (#2549)
Some checks are pending
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Waiting to run
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Waiting to run
Bazel presubmit checks / other-bazel-checks (push) Waiting to run
Check Configs / check-configs (push) Waiting to run
CMake / build (push) Waiting to run
Build on macOS / build (push) Waiting to run
Build on Windows / build (push) Waiting to run
Some checks are pending
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Waiting to run
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Waiting to run
Bazel presubmit checks / other-bazel-checks (push) Waiting to run
Check Configs / check-configs (push) Waiting to run
CMake / build (push) Waiting to run
Build on macOS / build (push) Waiting to run
Build on Windows / build (push) Waiting to run
* Update makefsdata.py to support content encoding changed makefsdata.py slightly to allow it to recognize files that have been manually gzipped (e.g. "mysite.css.gz") to send the proper Content-Encoding information in the response headers. * Code review fix --------- Co-authored-by: Peter Harper <peter.harper@raspberrypi.com>
This commit is contained in:
parent
a72865be12
commit
19904be31f
1 changed files with 10 additions and 4 deletions
|
|
@ -19,7 +19,7 @@ def process_file(input_dir, file):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
# Check content type
|
# Check content type
|
||||||
content_type, _ = mimetypes.guess_type(file)
|
content_type, content_encoding = mimetypes.guess_type(file)
|
||||||
if content_type is None:
|
if content_type is None:
|
||||||
content_type = "application/octet-stream"
|
content_type = "application/octet-stream"
|
||||||
|
|
||||||
|
|
@ -53,9 +53,15 @@ def process_file(input_dir, file):
|
||||||
comment = f"\"Content-Length: {file_size}\" ({len(data)} chars)"
|
comment = f"\"Content-Length: {file_size}\" ({len(data)} chars)"
|
||||||
results.append({'data': bytes(data, "utf-8"), 'comment': comment});
|
results.append({'data': bytes(data, "utf-8"), 'comment': comment});
|
||||||
|
|
||||||
# content type
|
# content type and content encoding
|
||||||
data = f"Content-Type: {content_type}\r\n\r\n"
|
content_type_header = f"Content-Type: {content_type}"
|
||||||
comment = f"\"Content-Type: {content_type}\" ({len(data)} chars)"
|
if content_encoding is None:
|
||||||
|
data = f"{content_type_header}\r\n\r\n"
|
||||||
|
comment = f"\"{content_type_header}\" ({len(data)} chars)"
|
||||||
|
else:
|
||||||
|
content_encoding_header = f"Content-Encoding: {content_encoding}"
|
||||||
|
data = f"{content_type_header}\r\n{content_encoding_header}\r\n\r\n"
|
||||||
|
comment = f"\"{content_type_header} {content_encoding_header}\" ({len(data)} chars)"
|
||||||
results.append({'data': bytes(data, "utf-8"), 'comment': comment});
|
results.append({'data': bytes(data, "utf-8"), 'comment': comment});
|
||||||
|
|
||||||
# file contents
|
# file contents
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue