mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
Use RocList::from_iter in sendRequest
This commit is contained in:
parent
d55d1b00d9
commit
a2b130a3c3
1 changed files with 5 additions and 13 deletions
|
@ -145,21 +145,13 @@ pub extern "C" fn roc_fx_sendRequest(roc_request: &glue::Request) -> glue::Respo
|
|||
.map(|val| val.max(BODY_MAX_BYTES))
|
||||
.unwrap_or(BODY_MAX_BYTES);
|
||||
|
||||
let mut bytes: Vec<u8> = Vec::with_capacity(len);
|
||||
match response
|
||||
let bytes_iter = response
|
||||
.into_reader()
|
||||
.take(len as u64)
|
||||
.read_to_end(&mut bytes)
|
||||
{
|
||||
Ok(_read_bytes) => {}
|
||||
Err(_) => {
|
||||
// Not totally accurate, but let's deal with this later when we do async
|
||||
return glue::Response::NetworkError;
|
||||
}
|
||||
}
|
||||
.bytes()
|
||||
.take(len)
|
||||
.filter_map(|result| result.ok());
|
||||
|
||||
// Note: we could skip a full memcpy if we had `RocList::from_iter`.
|
||||
let body = RocList::from_slice(&bytes);
|
||||
let body: RocList<u8> = RocList::from_iter(bytes_iter);
|
||||
|
||||
let metadata = Metadata {
|
||||
headers: RocList::empty(), // TODO
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue