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