Serve the Mews Profile stylesheet from an embedded copy

mews_profile pins both the stylesheet's name and its content, so a site
never actually chooses either; leaving the file itself to be placed in
every content root by hand just gave operators a way to get it stale or
missing. The byte-for-byte copy from mews.page/spec 5.1 now ships in the
binary and resolves `mews-0.1.css` at any depth, matching how a page's
relative link to it resolves, across every protocol that can hit it.
This commit is contained in:
randogoth 2026-10-11 10:14:49 +03:00
parent c9bde15f5c
commit 3e659df9dd
8 changed files with 170 additions and 1 deletions

View file

@ -68,6 +68,9 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
std::io::copy(&mut file, &mut stream)?;
Ok(())
}
Ok(Resolution::Found(Resource::Embedded { bytes, media_type })) => {
body_response(&mut stream, media_type, bytes)
}
Ok(Resolution::Redirect(location)) => header(&mut stream, 31, &location),
Ok(Resolution::NotFound) => header(&mut stream, 51, "Not found"),
Err(err) => {

View file

@ -55,6 +55,10 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
std::io::copy(&mut file, &mut stream)?;
Ok(())
}
Ok(Resolution::Found(Resource::Embedded { bytes, .. })) => {
stream.write_all(bytes)?;
Ok(())
}
// resolve_flat follows redirects and sub-documents to real content.
Ok(_) => text(&mut stream, b"Not found\n"),
Err(err) => {

View file

@ -175,6 +175,9 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
}
Ok(())
}
Ok(Resolution::Found(Resource::Embedded { bytes, media_type })) => {
respond(&mut stream, 200, "OK", media_type, bytes, &[], head_only)
}
Ok(Resolution::Redirect(location)) => respond(
&mut stream,
301,

View file

@ -45,6 +45,9 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
let mut file = std::fs::File::open(&path)?;
std::io::copy(&mut file, &mut stream)?;
}
Ok(Resolution::Found(Resource::Embedded { bytes, .. })) => {
stream.write_all(bytes)?;
}
// resolve_flat follows redirects and sub-documents to real content, so
// neither reaches here; they are matched for completeness.
Ok(_) => stream.write_all(b"Not found\n")?,

View file

@ -73,6 +73,9 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
std::io::copy(&mut file, &mut stream)?;
Ok(())
}
Ok(Resolution::Found(Resource::Embedded { bytes, media_type })) => {
status(&mut stream, 2, media_type, bytes)
}
Ok(Resolution::Redirect(location)) => status(&mut stream, 3, &location, b""),
Ok(Resolution::NotFound) => status(&mut stream, 4, "Not found", b""),
Err(err) => {