Open liudonghua123 opened 8 months ago
Please provide more information and a reproduction repo and how tiny-http
is used
Please provide more information and a reproduction repo and how
tiny-http
is used
I did not use tiny-http
, it's just the response header (Server: tiny-http (Rust)).
The only changes I made is the following after I execute yarn create tauri-app
.
[package]
name = "tauri-app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.5", features = [] }
[dependencies]
# https://docs.rs/tauri/latest/tauri/
tauri = { version = "1.5", features = ["devtools", "http-multipart", "shell-open"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
# tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
portpicker = "0.1" # used in the example to pick a random free port
[features]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::{utils::config::AppUrl, WindowUrl};
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
fn main() {
let port = portpicker::pick_unused_port().expect("failed to find unused port");
let mut context = tauri::generate_context!();
let url = format!("http://localhost:{}", port).parse().unwrap();
let window_url = WindowUrl::External(url);
// rewrite the config so the IPC is enabled on this URL
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());
tauri::Builder::default()
//.plugin(tauri_plugin_shell::init())
.plugin(
tauri_plugin_localhost::Builder::new(port)
.on_request(|_req, resp| {
resp.add_header("Cross-Origin-Opener-Policy", "same-origin");
resp.add_header("Cross-Origin-Embedder-Policy", "require-corp");
})
.build(),
)
.invoke_handler(tauri::generate_handler![greet])
.run(context)
.expect("error while running tauri application");
}
build.distDir
of tauri.conf.json.I read https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests and https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding, it seems the default configured tauri serve do not support Accept-Ranges: bytes
.
I found the doc https://docs.rs/tauri/latest/tauri/api/http/header/constant.ACCEPT_RANGES.html, and I tried to add "http-api" features, but it's the same, the server did not reply Accept-Ranges
and did not support requesting a specific range of resource. Maybe I need to go through the code and find what I missed.
Please provide more information and a reproduction repo and how
tiny-http
is used
@amrbashir Hi, I use tauri-plugin-localhost
plugin which supports adding Cross-Origin-Opener-Policy: same-origin
and Cross-Origin-Embedder-Policy: require-corp
and serve the static files via http://localhost:<some_port>
which is needed to enable SharedArrayBuffer.
But the tiny-http lib does not support ranges features currently.
Is there any method which I can enable SharedArrayBuffer in tauri and support http range feature.
I found maybe I can replace the tiny-http
with http-serve
which provides more complete http server features like range in a forked tauri-plugin-localhost
plugin. But I am not familiar with rust.
I see, I will move the issue to plugins-workspace then
Describe the bug
Hi, I tried to use tauri to package some static files (webvm), and I found one resource
/debian_mini_20240103_7393161196.ext2
request returnedContent-Type: text/html
andTransfer-Encoding: chunked
.The mime type of unknown file maybe represent as binary file (
Content-Type: application/octet-stream
).Reproduction
No response
Expected behavior
I expected the server returned
Content-Type: application/octet-stream
andContent-Range: bytes 0-1/629145600
for/debian_mini_20240103_7393161196.ext2
.Full
tauri info
outputStack trace
No response
Additional context
How can I configure/overwrite the mime type of a specified resource? And is there any way to make the response return
Content-Length
andContent-Range
instead ofTransfer-Encoding: chunked
.I also posted a discussion on https://github.com/tauri-apps/tauri/discussions/8533.