tauri-apps / tauri-apps/plugins-workspace
plugin-http closes the connection whenever keep-alive is set
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
I was accesing an API endpoint and opening the connection takes around 5 secs which is very annoying, and keep-alive can easily fix this.
In WebView2, keep-alive works fine, and in tauri, connection is closed after every fetch, so it takes HUGE amounts of time to send multiple requests to the server.
code (with unsafe headers enabled and url whitelisted)
```js
import { fetch } from "@tauri-apps/plugin-http"
async function debug() {
for (let index = 0; index < 5; index++) {
const response = await fetch("https://httpbin.org/headers", {
method: "GET",
headers: {
Connection: "keep-alive",
},
})
console.log("request "+ index, await response.json())
}
}
await debug()
```
you can use packet tracers to see the connection is closed after a request has finished
Contributor guide
Assessment
This issue has not been assessed yet.