Dever v0.0.2

This commit is contained in:
Codex committed 2026-11-27 06:03:56 +00:00
commit e6e175ebcf
816 files changed
+120349

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
use dever_runtime::{Bytes, http, net, task, tls};
task::run(true, 32, async |scope| {
let listener = net::listen("127.0.0.1", 0, scope).await.unwrap();
let origin = format!("http://localhost:{}", listener.port().unwrap());
let active = listener.clone();
let server = scope.spawn(move |child| async move {
http::serve::<false, _, _>(&child, |request, _| async move {
assert_eq!(request.target, "/pooled");
Ok(http::Response { status: 201, headers: vec![], body: request.body })
}, &active, &http::Limits { header_bytes: 8192, body_bytes: 1048576, timeout_ms: 1000, connections: 32, http2: None }, None).await
}).unwrap();
let client = @open@(scope, &origin, &tls::system()).await.unwrap();
let response = @fetch@(&client, Bytes::from_static(b"one")).await.unwrap();
assert_eq!(response.status, 201);
assert_eq!(response.body, b"one"[..]);
let response = @queued@(scope, client.clone(), Bytes::from_static(b"two")).await.unwrap();
assert_eq!(response.body, b"two"[..]);
assert_eq!(@download@(&client, Bytes::from_static(b"streamed")).await.unwrap(), 8);
assert_eq!(@upload@(&client, Bytes::from_static(b"uploaded")).await.unwrap(), 8);
@close@(&client).await.unwrap();
assert!(@fetch@(&client, Bytes::new()).await.is_err());
listener.close().unwrap();
server.await.unwrap().unwrap();
Ok::<_, ()>(())
}).unwrap().unwrap();