Skip to content

Commit 6f15993

Browse files
committed
..
1 parent a2d58b4 commit 6f15993

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

lib/executor/src/executors/compression.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ impl CompressionType {
3030
.iter()
3131
.map(|t| t.header_value().to_string())
3232
.collect::<Vec<String>>()
33-
.join(", ")
34-
.to_string(),
33+
.join(", "),
3534
}
3635
}
3736
pub fn from_encoding_header(encoding: &str) -> Result<CompressionType, SubgraphExecutorError> {
@@ -63,45 +62,45 @@ impl CompressionType {
6362
CompressionType::Gzip => {
6463
let mut decoder = GzipDecoder::new(body.as_ref());
6564
let mut buf = Vec::new();
66-
let _ = decoder.read_to_end(&mut buf).await.map_err(|e| {
65+
decoder.read_to_end(&mut buf).await.map_err(|e| {
6766
SubgraphExecutorError::DecompressionFailed(
6867
self.header_value(),
6968
e.to_string(),
7069
)
71-
});
70+
})?;
7271
Ok(Bytes::from(buf))
7372
}
7473
CompressionType::Deflate => {
7574
let mut decoder = DeflateDecoder::new(body.as_ref());
7675
let mut buf = Vec::new();
77-
let _ = decoder.read_to_end(&mut buf).await.map_err(|e| {
76+
decoder.read_to_end(&mut buf).await.map_err(|e| {
7877
SubgraphExecutorError::DecompressionFailed(
7978
self.header_value(),
8079
e.to_string(),
8180
)
82-
});
81+
})?;
8382
Ok(Bytes::from(buf))
8483
}
8584
CompressionType::Brotli => {
8685
let mut decoder = BrotliDecoder::new(body.as_ref());
8786
let mut buf = Vec::new();
88-
let _ = decoder.read_to_end(&mut buf).await.map_err(|e| {
87+
decoder.read_to_end(&mut buf).await.map_err(|e| {
8988
SubgraphExecutorError::DecompressionFailed(
9089
self.header_value(),
9190
e.to_string(),
9291
)
93-
});
92+
})?;
9493
Ok(Bytes::from(buf))
9594
}
9695
CompressionType::Zstd => {
9796
let mut decoder = ZstdDecoder::new(body.as_ref());
9897
let mut buf = Vec::new();
99-
let _ = decoder.read_to_end(&mut buf).await.map_err(|e| {
98+
decoder.read_to_end(&mut buf).await.map_err(|e| {
10099
SubgraphExecutorError::DecompressionFailed(
101100
self.header_value(),
102101
e.to_string(),
103102
)
104-
});
103+
})?;
105104
Ok(Bytes::from(buf))
106105
}
107106
CompressionType::Multiple(types) => {

lib/executor/src/executors/http.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,9 @@ impl HTTPSubgraphExecutor {
181181
.and_then(|v| v.to_str().ok());
182182

183183
if let Some(content_encoding_header) = content_encoding_header {
184-
let decompressor = CompressionType::from_encoding_header(content_encoding_header)
185-
.map_err(|e| {
186-
SubgraphExecutorError::RequestFailure(self.endpoint.to_string(), e.to_string())
187-
})?;
184+
let decompressor = CompressionType::from_encoding_header(content_encoding_header)?;
188185

189-
body = decompressor.decompress(body).await.map_err(|e| {
190-
SubgraphExecutorError::RequestFailure(self.endpoint.to_string(), e.to_string())
191-
})?;
186+
body = decompressor.decompress(body).await?;
192187
}
193188

194189
if body.is_empty() {

0 commit comments

Comments
 (0)