Skip to content

Commit fcdd782

Browse files
committed
Unnecessary BoxBody
1 parent 0e77f59 commit fcdd782

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

crates/roc_http/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
//! This crate provides common functionality for Roc to interface with `std::net::tcp`
22
use roc_std::{RocBox, RocList, RocRefcounted, RocResult, RocStr};
33
use roc_std_heap::ThreadSafeRefcountedResourceHeap;
4-
use std::convert::Infallible;
54
use std::env;
65
use std::io::{BufRead, BufReader, ErrorKind, Read, Write};
76
use std::net::TcpStream;
87
use std::sync::OnceLock;
98
use bytes::Bytes;
10-
use http_body_util::BodyExt;
119

1210
pub const REQUEST_TIMEOUT_BODY: &[u8] = "RequestTimeout".as_bytes();
1311
pub const REQUEST_NETWORK_ERR: &[u8] = "Network Error".as_bytes();
1412
pub const REQUEST_BAD_BODY: &[u8] = "Bad Body".as_bytes();
1513

16-
type BoxBody = http_body_util::combinators::BoxBody<Bytes, Infallible>;
17-
1814
pub fn heap() -> &'static ThreadSafeRefcountedResourceHeap<BufReader<TcpStream>> {
1915
// TODO: Should this be a BufReader and BufWriter of the tcp stream?
2016
// like this: https://stackoverflow.com/questions/58467659/how-to-store-tcpstream-with-bufreader-and-bufwriter-in-a-data-structure/58491889#58491889
@@ -196,7 +192,7 @@ impl From<hyper::http::Error> for ResponseToAndFromHost {
196192
}
197193
}
198194

199-
impl From<ResponseToAndFromHost> for hyper::Response<BoxBody> {
195+
impl From<ResponseToAndFromHost> for hyper::Response<http_body_util::Full<Bytes>> {
200196
fn from(roc_response: ResponseToAndFromHost) -> Self {
201197
let mut builder = hyper::Response::builder();
202198

@@ -211,7 +207,7 @@ impl From<ResponseToAndFromHost> for hyper::Response<BoxBody> {
211207
}
212208

213209
builder
214-
.body(http_body_util::Full::new(Vec::from(roc_response.body.as_slice()).into()).boxed()) // TODO try not to use Vec here
210+
.body(http_body_util::Full::new(Vec::from(roc_response.body.as_slice()).into())) // TODO try not to use Vec here
215211
.unwrap() // TODO don't unwrap this
216212
}
217213
}

0 commit comments

Comments
 (0)