wip: feat: update h3 response reader to use async stream

This commit is contained in:
Jun Kurihara 2023-12-11 16:52:54 +09:00
commit cc48394e73
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
4 changed files with 145 additions and 8 deletions

View file

@ -75,9 +75,12 @@ where
};
let (parts, body) = res.unwrap().into_parts();
// TODO: This is inefficient since current strategy needs to copy the whole body onto memory to cache it.
// This should be handled by copying buffer simultaneously while forwarding response to downstream.
let Ok(bytes) = body.collect().await.map(|v| v.to_bytes()) else {
return Err(RpxyError::FailedToWriteByteBufferForCache);
};
let bytes_clone = bytes.clone();
// TODO: this is inefficient. needs to be reconsidered to avoid unnecessary copy and should spawn async task to store cache.
// We may need to use the same logic as h3.