On 08.07.24 18:45, Jonas Smedegaard wrote:
Quoting Matthias Geiger (2024-07-07 11:21:07)
On 07.07.24 10:10, Jonas Smedegaard wrote:
[...]
[...]
isahc requires sluice only for some pipe functionality in two files.
Since patching sluice proves to be hard I'd
opt to patch isahc to use something like stdio::piped() rather than
sluice::pipe. Then I can file a RM request for sluice since it's not
used elsewhere and we can finish this transition.
Makes great sense.
I attached my wip for using os_pipe instead of sluice. Still has four
errors atm; I'd appreciate some knowledgable people looking into it
(CC'd ncts). I do not have any more time atm to sink into this; will
pick it up later unless someone beats me to it.
best,
werdahias
diff --git a/Cargo.toml b/Cargo.toml
index e1ab8ef..351fbc1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,6 +35,7 @@ unstable-interceptors = []
async-channel = "1.4.2"
castaway = "0.1.1"
crossbeam-utils = ">=0.7.0, <0.9.0"
+os_pipe = "*"
curl = "0.4.36"
curl-sys = "0.4.55"
event-listener = "2.3.3"
@@ -44,7 +45,6 @@ log = "0.4"
once_cell = "1"
polling = "2"
slab = "0.4"
-sluice = "0.5.4"
url = "2.1"
waker-fn = "1"
diff --git a/src/body/sync.rs b/src/body/sync.rs
index e035dee..fe6d380 100644
--- a/src/body/sync.rs
+++ b/src/body/sync.rs
@@ -1,11 +1,11 @@
use super::AsyncBody;
use futures_lite::{future::yield_now, io::AsyncWriteExt};
-use sluice::pipe::{pipe, PipeWriter};
+use os_pipe::{PipeWriter, pipe};
use std::{
borrow::Cow,
fmt,
fs::File,
- io::{Cursor, ErrorKind, Read, Result},
+ io::{Cursor, ErrorKind, Read, Result, Write},
};
/// Contains the body of a synchronous HTTP request or response.
@@ -158,7 +158,8 @@ impl Body {
Inner::Empty => (AsyncBody::empty(), None),
Inner::Buffer(cursor) => (AsyncBody::from_bytes_static(cursor.into_inner()), None),
Inner::Reader(reader, len) => {
- let (pipe_reader, writer) = pipe();
+
+ let Ok((pipe_reader, writer)) = pipe();
(
if let Some(len) = len {
@@ -275,7 +276,7 @@ impl Writer {
Err(e) => return Err(e),
};
- self.writer.write_all(&buf[..len]).await?;
+ self.writer.write_all(&buf[..len]);
}
}
}
diff --git a/src/handler.rs b/src/handler.rs
index 92445f6..05c9fc9 100644
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -14,7 +14,7 @@ use curl_sys::CURL;
use futures_lite::io::{AsyncRead, AsyncWrite};
use http::Response;
use once_cell::sync::OnceCell;
-use sluice::pipe;
+use os_pipe::{pipe, PipeReader};
use std::{
ascii,
ffi::CStr,
@@ -79,7 +79,7 @@ pub(crate) struct RequestHandler {
response_headers: http::HeaderMap,
/// Writing end of the pipe where the response body is written.
- response_body_writer: pipe::PipeWriter,
+ response_body_writer: os_pipe::PipeWriter,
/// A waker used with writing the response body asynchronously. Populated by
/// an agent when the request is initialized.
@@ -126,7 +126,7 @@ impl RequestHandler {
) {
let (sender, receiver) = async_channel::bounded(1);
let shared = Arc::new(Shared::default());
- let (response_body_reader, response_body_writer) = pipe::pipe();
+ let Ok((response_body_reader, response_body_writer)) = os_pipe::pipe() else { todo!() };
let handler = Self {
span: tracing::debug_span!("handler", id = tracing::field::Empty),
@@ -672,7 +672,8 @@ impl fmt::Debug for RequestHandler {
/// Wrapper around a pipe reader that returns an error that tracks transfer
/// cancellation.
pub(crate) struct ResponseBodyReader {
- inner: pipe::PipeReader,
+ inner: os_pipe::PipeReader,
+
shared: Arc<Shared>,
}