+45
-6
crates/jacquard-common/src/http_client.rs
+45
-6
crates/jacquard-common/src/http_client.rs
···
130
131
// Convert bytes_stream to ByteStream
132
use futures::StreamExt;
133
-
let stream = resp.bytes_stream().map(|result| {
134
-
result.map_err(|e| StreamError::transport(e))
135
-
});
136
let byte_stream = ByteStream::new(stream);
137
138
Ok(builder.body(byte_stream).expect("Failed to build response"))
139
}
140
141
async fn send_http_bidirectional<S>(
142
&self,
143
parts: http::request::Parts,
···
169
builder = builder.header(name.as_str(), value.as_bytes());
170
}
171
172
-
let stream = resp.bytes_stream().map(|result| {
173
-
result.map_err(|e| StreamError::transport(e))
174
-
});
175
let byte_stream = ByteStream::new(stream);
176
177
Ok(builder.body(byte_stream).expect("Failed to build response"))
···
130
131
// Convert bytes_stream to ByteStream
132
use futures::StreamExt;
133
+
let stream = resp
134
+
.bytes_stream()
135
+
.map(|result| result.map_err(|e| StreamError::transport(e)));
136
let byte_stream = ByteStream::new(stream);
137
138
Ok(builder.body(byte_stream).expect("Failed to build response"))
139
}
140
141
+
#[cfg(not(target_arch = "wasm32"))]
142
async fn send_http_bidirectional<S>(
143
&self,
144
parts: http::request::Parts,
···
170
builder = builder.header(name.as_str(), value.as_bytes());
171
}
172
173
+
let stream = resp
174
+
.bytes_stream()
175
+
.map(|result| result.map_err(|e| StreamError::transport(e)));
176
+
let byte_stream = ByteStream::new(stream);
177
+
178
+
Ok(builder.body(byte_stream).expect("Failed to build response"))
179
+
}
180
+
181
+
#[cfg(target_arch = "wasm32")]
182
+
async fn send_http_bidirectional<S>(
183
+
&self,
184
+
parts: http::request::Parts,
185
+
body: S,
186
+
) -> Result<http::Response<ByteStream>, Self::Error>
187
+
where
188
+
S: n0_future::Stream<Item = bytes::Bytes> + Send + 'static,
189
+
{
190
+
// Convert stream to reqwest::Body
191
+
use futures::StreamExt;
192
+
193
+
let mut req = self
194
+
.request(parts.method, parts.uri.to_string())
195
+
.body(reqwest_body);
196
+
197
+
// Copy headers
198
+
for (name, value) in parts.headers.iter() {
199
+
req = req.header(name.as_str(), value.as_bytes());
200
+
}
201
+
202
+
// Send and convert response
203
+
let resp = req.send().await?;
204
+
205
+
let mut builder = http::Response::builder().status(resp.status());
206
+
207
+
for (name, value) in resp.headers().iter() {
208
+
builder = builder.header(name.as_str(), value.as_bytes());
209
+
}
210
+
211
+
let stream = resp
212
+
.bytes_stream()
213
+
.map(|result| result.map_err(|e| StreamError::transport(e)));
214
let byte_stream = ByteStream::new(stream);
215
216
Ok(builder.body(byte_stream).expect("Failed to build response"))
+2
-2
crates/jacquard-lexicon/Cargo.toml
+2
-2
crates/jacquard-lexicon/Cargo.toml
···
26
heck.workspace = true
27
#itertools.workspace = true
28
jacquard-api = { version = "0.5", git = "https://tangled.org/@nonbinary.computer/jacquard" }
29
-
jacquard-common = { version = "0.5", git = "https://tangled.org/@nonbinary.computer/jacquard" }
30
jacquard-identity = { version = "0.5", git = "https://tangled.org/@nonbinary.computer/jacquard" }
31
kdl = "6"
32
miette = { workspace = true, features = ["fancy"] }
33
prettyplease.workspace = true
34
proc-macro2.workspace = true
35
quote.workspace = true
36
-
reqwest.workspace = true
37
serde.workspace = true
38
serde_json.workspace = true
39
serde_repr.workspace = true
···
26
heck.workspace = true
27
#itertools.workspace = true
28
jacquard-api = { version = "0.5", git = "https://tangled.org/@nonbinary.computer/jacquard" }
29
+
jacquard-common = { version = "0.5", features = [ "reqwest-client" ], git = "https://tangled.org/@nonbinary.computer/jacquard" }
30
jacquard-identity = { version = "0.5", git = "https://tangled.org/@nonbinary.computer/jacquard" }
31
kdl = "6"
32
miette = { workspace = true, features = ["fancy"] }
33
prettyplease.workspace = true
34
proc-macro2.workspace = true
35
quote.workspace = true
36
+
reqwest = { workspace = true, features = ["json", "http2", "system-proxy", "rustls-tls"] }
37
serde.workspace = true
38
serde_json.workspace = true
39
serde_repr.workspace = true