11//! This crate provides common functionality for Roc to interface with `std::net::tcp`
22use roc_std:: { RocBox , RocList , RocRefcounted , RocResult , RocStr } ;
33use roc_std_heap:: ThreadSafeRefcountedResourceHeap ;
4- use std:: convert:: Infallible ;
54use std:: env;
65use std:: io:: { BufRead , BufReader , ErrorKind , Read , Write } ;
76use std:: net:: TcpStream ;
87use std:: sync:: OnceLock ;
98use bytes:: Bytes ;
10- use http_body_util:: BodyExt ;
119
1210pub const REQUEST_TIMEOUT_BODY : & [ u8 ] = "RequestTimeout" . as_bytes ( ) ;
1311pub const REQUEST_NETWORK_ERR : & [ u8 ] = "Network Error" . as_bytes ( ) ;
1412pub const REQUEST_BAD_BODY : & [ u8 ] = "Bad Body" . as_bytes ( ) ;
1513
16- type BoxBody = http_body_util:: combinators:: BoxBody < Bytes , Infallible > ;
17-
1814pub 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