Skip to content

Commit 4e724a5

Browse files
authored
Merge pull request #317 from libre-embedded/dev/5.13.3
5.13.3 - Updates from browser findings
2 parents 77d6026 + c27cbea commit 4e724a5

File tree

9 files changed

+31
-17
lines changed

9 files changed

+31
-17
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
7979
- run: |
8080
mk python-release owner=libre-embedded \
81-
repo=runtimepy version=5.13.2
81+
repo=runtimepy version=5.13.3
8282
if: |
8383
matrix.python-version == '3.12'
8484
&& matrix.system == 'ubuntu-latest'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
=====================================
33
generator=datazen
44
version=3.2.3
5-
hash=f3bcab8765e649f1b80ad504e5debde9
5+
hash=7dce65a7ea83c118cf5fa28ddbfd533f
66
=====================================
77
-->
88

9-
# runtimepy ([5.13.2](https://pypi.org/project/runtimepy/))
9+
# runtimepy ([5.13.3](https://pypi.org/project/runtimepy/))
1010

1111
[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
1212
![Build Status](https://github.com/libre-embedded/runtimepy/workflows/Python%20Package/badge.svg)

local/variables/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
major: 5
33
minor: 13
4-
patch: 2
4+
patch: 3
55
entry: runtimepy

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
44

55
[project]
66
name = "runtimepy"
7-
version = "5.13.2"
7+
version = "5.13.3"
88
description = "A framework for implementing Python services."
99
readme = "README.md"
1010
requires-python = ">=3.12"

runtimepy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.2.3
4-
# hash=6693eae62108cbcdfbccdb9de6b57fa8
4+
# hash=940af0fb662bf9b9e98e5ce5df85b4b2
55
# =====================================
66

77
"""
@@ -10,7 +10,7 @@
1010

1111
DESCRIPTION = "A framework for implementing Python services."
1212
PKG_NAME = "runtimepy"
13-
VERSION = "5.13.2"
13+
VERSION = "5.13.3"
1414

1515
# runtimepy-specific content.
1616
METRICS_NAME = "metrics"

runtimepy/data/404.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<html lang=en><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>runtimepy/5.12.0</title><style>@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-Regular.woff2)}@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-Bold.woff2);font-weight:700}@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-BoldItalic.woff2);font-weight:700;font-style:italic}@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-Italic.woff2);font-style:italic}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-Regular.woff2)}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-Bold.woff2);font-weight:700}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-BoldItalic.woff2);font-weight:700;font-style:italic}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-Italic.woff2);font-style:italic}</style><link rel=stylesheet href=/static/css/bootstrap-icons.min.css></link>
2-
<link href=/static/css/bootstrap.min.css rel=stylesheet crossorigin=anonymous></link><style>html{height:100%;width:100%;position:fixed}body{height:100%;margin:0;overflow:hidden}body>:first-child{height:100%}#runtimepy{height:100%}#runtimepy-tabs{width:min-content}#runtimepy-splash{position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:1}.click-plot{cursor:pointer}.stale{color:var(--bs-warning-text-emphasis)!important}.slider{min-width:8em}.toggle-value{}.window-button{border-right:var(--bs-border-width)var(--bs-border-style)var(--bs-link-hover-color)!important}canvas:focus{outline:none}.flex-column-scroll-bodge{height:100%;flex-wrap:nowrap;overflow-y:scroll;flex-shrink:0}.scroll{overflow:scroll}.tab-content-bodge{width:100%;height:100%}.button-bodge{text-align:left}.collapsing{transition:none!important}.tab-pane.fade{transition:none!important}.modal.fade{transition:none!important}.modal-dialog{width:80%;max-width:80%}.table{margin-bottom:0;width:auto}.table-container{overflow-x:scroll;min-height:fit-content}.channel-column{overflow-y:scroll;overflow-x:hidden;flex-grow:0;flex-shrink:0;max-width:75%}.channel-value{min-width:10em}.table>tbody>tr>td{vertical-align:middle}.collapse:not(.show){display:none!important}select.form-select{width:min-content}select.form-select:hover{cursor:pointer}textarea.text-logs{min-height:10em!important;padding-top:0!important;padding-bottom:0!important;border-top:0}.vertical-divider{flex-basis:.75em;flex-grow:0;flex-shrink:0}pre{color:var(--bs-code-color)}.vertical-divider:hover{cursor:col-resize;background-color:var(--bs-highlight-bg)!important}button:hover{background-color:var(--bs-tertiary-bg)}.channel-value-input{width:6em}:root,[data-bs-theme=dark],[data-bs-theme=light]{--bs-font-sans-serif:CascadiaCode, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--bs-font-monospace:CascadiaMono, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace}</style><div id=runtimepy class="align-items-start d-flex bg-body" data-bs-theme=dark><div class="d-flex h-100 bg-dark-subtle flex-column"><button type=button id=theme-button class="btn btn-secondary rounded-0 font-monospace button-bodge text-nowrap has-tooltip" data-bs-title=" Toggle light/dark." data-bs-placement=right>
1+
<!doctype html><html lang=en><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Libre Embedded - Home
2+
</title><meta http-equiv=Cache-Control content="public"><link rel=icon href=/favicon.ico><meta name=description content="Libre Embedded Engineering Technologies LLC is an engineering consultancy and product development company. This page was rendered from Markdown by runtimepy/5.13.3."><style>@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-Regular.woff2)}@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-Bold.woff2);font-weight:700}@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-BoldItalic.woff2);font-weight:700;font-style:italic}@font-face{font-family:CascadiaCode;src:url(/static/woff2/CascadiaCode-Italic.woff2);font-style:italic}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-Regular.woff2)}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-Bold.woff2);font-weight:700}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-BoldItalic.woff2);font-weight:700;font-style:italic}@font-face{font-family:CascadiaMono;src:url(/static/woff2/CascadiaMono-Italic.woff2);font-style:italic}</style><link rel=stylesheet href=/static/css/bootstrap-icons.min.css></link>
3+
<link href=/static/css/bootstrap.min.css rel=stylesheet crossorigin=anonymous></link><style>html{height:100%;width:100%;position:fixed}body{height:100%;margin:0;overflow:hidden}body>:first-child{height:100%}#runtimepy{height:100%}#runtimepy-tabs{width:min-content}#runtimepy-splash{position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:1}.click-plot{cursor:pointer}.stale{color:var(--bs-warning-text-emphasis)!important}.slider{min-width:8em}.toggle-value{}.window-button{border-right:var(--bs-border-width)var(--bs-border-style)var(--bs-link-hover-color)!important}:focus{outline:none}.flex-column-scroll-bodge{height:100%;flex-wrap:nowrap;overflow-y:scroll;flex-shrink:0}.scroll{overflow:scroll}.tab-content-bodge{width:100%;height:100%}.button-bodge{text-align:left}.collapsing{transition:none!important}.tab-pane.fade{transition:none!important}.modal.fade{transition:none!important}.modal-dialog{width:80%;max-width:80%}.table{margin-bottom:0;width:auto}.table-container{overflow-x:scroll;min-height:fit-content}.channel-column{overflow-y:scroll;overflow-x:hidden;flex-grow:0;flex-shrink:0;max-width:75%}.channel-value{min-width:10em}.table>tbody>tr>td{vertical-align:middle}.collapse:not(.show){display:none!important}select.form-select{width:min-content}select.form-select:hover{cursor:pointer}textarea.text-logs{min-height:10em!important;padding-top:0!important;padding-bottom:0!important;border-top:0}.vertical-divider{flex-basis:.75em;flex-grow:0;flex-shrink:0}pre{color:var(--bs-code-color)}.vertical-divider:hover{cursor:col-resize;background-color:var(--bs-highlight-bg)!important}button:hover{background-color:var(--bs-tertiary-bg)}.channel-value-input{width:6em}:root,[data-bs-theme=dark],[data-bs-theme=light]{--bs-font-sans-serif:CascadiaCode, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--bs-font-monospace:CascadiaMono, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace}</style><div id=runtimepy class="d-flex bg-body align-items-start" data-bs-theme=dark><div class="bg-dark-subtle d-flex h-100 flex-column"><button type=button id=theme-button title="change theme button" class="btn btn-secondary rounded-0 font-monospace button-bodge text-nowrap has-tooltip" data-bs-title="Toggle light/dark." data-bs-placement=right>
34
<i class="bi bi-lightbulb"></i>
45
</button>
5-
<a href="?print=true"><button type=button id=print-button class="btn btn-secondary rounded-0 font-monospace button-bodge text-nowrap has-tooltip" data-bs-title="Printer-friendly view." data-bs-placement=right>
6-
<i class="bi bi-printer"></i></button></a></div><div class="d-flex h-100 justify-content-between flex-grow-1 flex-column overflow-y-auto text-body"><div></div><div class="d-flex flex-row justify-content-between"><div></div><div class="text-body p-3 pb-0"><h1><a href=/><img alt=logo src=/static/png/chip-circle-bootstrap/128x128.png></a> Resource Not Found (404) <a href=/><img alt=logo src=/static/png/chip-circle-bootstrap/128x128.png></a></h1><p>(<a href=/>home</a>)</div><div></div></div><div></div></div></div><script>function worker_config(e){let t={},s="runtimepy_websocket",n="ws";location.protocol.includes("https")&&(s="runtimepy_secure_websocket",n+="s");let o=e.config.ports;for(let r in o){let i=o[r],a=e.config.websocket_hostname||window.location.hostname;i.name.includes(s)&&(i.name.includes("data")?t.data=`${n}://${a}:`+i.port:t.json=`${n}://${a}:`+i.port)}return t}let tabFilter=void 0;function bootstrap_init(){const t=document.querySelectorAll(".has-tooltip"),n=[...t].map(e=>new bootstrap.Tooltip(e));let e=document.getElementById("runtimepy-tabs");e&&(tabFilter=new TabFilter(e))}let lightMode=!1;function lightDarkClick(){lightMode=!lightMode,document.getElementById("runtimepy").setAttribute("data-bs-theme",lightMode?"light":"dark"),window.location.hash=lightMode?"#light-mode":""}window.onload=()=>{let e=document.getElementById("theme-button");if(e&&e.addEventListener("click",lightDarkClick),window.location.hash){let t=window.location.hash.slice(1).split(",");t.includes("light-mode")&&e.click()}bootstrap_init()}</script><script src=/static/js/bootstrap.bundle.min.js crossorigin=anonymous></script>
6+
<a href="?print=true"><button type=button id=print-button title="print-view button" class="btn btn-secondary rounded-0 font-monospace button-bodge text-nowrap has-tooltip" data-bs-title="Printer-friendly view." data-bs-placement=right>
7+
<i class="bi bi-printer"></i></button></a></div><div class="h-100 flex-grow-1 justify-content-between text-body d-flex overflow-y-auto flex-column"><div></div><div class="justify-content-between d-flex flex-row"><div></div><div class="text-body p-3 pb-0"><h1><a href=/><img alt=logo src=/static/png/chip-circle-bootstrap/128x128.png></a> Resource Not Found (404) <a href=/><img alt=logo src=/static/png/chip-circle-bootstrap/128x128.png></a></h1><p>(<a href=/>home</a>)</div><div></div></div><div></div></div></div><script>function worker_config(e){let t={},s="runtimepy_websocket",n="ws";location.protocol.includes("https")&&(s="runtimepy_secure_websocket",n+="s");let o=e.config.ports;for(let r in o){let i=o[r],a=e.config.websocket_hostname||window.location.hostname;i.name.includes(s)&&(i.name.includes("data")?t.data=`${n}://${a}:`+i.port:t.json=`${n}://${a}:`+i.port)}return t}let tabFilter=void 0;function bootstrap_init(){const t=document.querySelectorAll(".has-tooltip"),n=[...t].map(e=>new bootstrap.Tooltip(e));let e=document.getElementById("runtimepy-tabs");e&&(tabFilter=new TabFilter(e))}let lightMode=!1;function lightDarkClick(){lightMode=!lightMode,document.getElementById("runtimepy").setAttribute("data-bs-theme",lightMode?"light":"dark"),window.location.hash=lightMode?"#light-mode":""}window.onload=()=>{let e=document.getElementById("theme-button");if(e&&e.addEventListener("click",lightDarkClick),window.location.hash){let t=window.location.hash.slice(1).split(",");t.includes("light-mode")&&e.click()}bootstrap_init()}</script><script src=/static/js/bootstrap.bundle.min.js crossorigin=anonymous></script>

runtimepy/net/http/response.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ def log(self, logger: LoggerType, out: bool, **_) -> None:
8888
self.headers,
8989
)
9090

91+
def static_resource(
92+
self, value: str = "public, max-age=31536000, immutable"
93+
) -> None:
94+
"""Set headers for static resources."""
95+
96+
self["Cache-Control"] = value
97+
9198

9299
class AsyncResponse:
93100
"""

runtimepy/net/server/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ async def try_file(
237237

238238
self.logger.info("Serving '%s' (MIME: %s)", candidate, mime)
239239

240+
response.static_resource()
241+
240242
# Return the file data.
241243
result = AsyncResponse(candidate)
242244
break
@@ -321,6 +323,7 @@ async def get_handler(
321323
# Handle favicon (for browser clients).
322324
if path.startswith("/favicon"):
323325
response["Content-Type"] = "image/x-icon"
326+
response.static_resource()
324327
return self.favicon_data
325328

326329
# Try serving a file and handling redirects.

runtimepy/net/tcp/http/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ class HttpConnection(_TcpConnection):
6868
# runtime don't need additional initialization.
6969
handlers: HttpRequestHandlers = {}
7070

71+
headers: dict[str, str] = {
72+
"Server": PKG_NAME,
73+
"X-Content-Type-Options": "nosniff",
74+
"Cache-Control": "public",
75+
}
76+
7177
def init(self) -> None:
7278
"""Initialize this instance."""
7379

@@ -128,12 +134,9 @@ async def _process_request(
128134
f"No handler for {request_header.method} requests."
129135
)
130136

131-
# Set boilerplate header data.
132-
133-
# webhint suggestions
134-
# response["server"] = self.identity
135-
response["server"] = PKG_NAME
136-
response["X-Content-Type-Options"] = "nosniff"
137+
for key, value in type(self).headers.items():
138+
if response.get(key) is None:
139+
response[key] = value
137140

138141
return result
139142

0 commit comments

Comments
 (0)