@@ -12,6 +12,7 @@ use deno_core::futures::future::poll_fn;
12
12
use deno_core:: op2;
13
13
use deno_core:: serde:: Serialize ;
14
14
use deno_core:: AsyncRefCell ;
15
+ use deno_core:: BufView ;
15
16
use deno_core:: ByteString ;
16
17
use deno_core:: CancelFuture ;
17
18
use deno_core:: CancelHandle ;
@@ -34,7 +35,7 @@ use reqwest::header::HeaderValue;
34
35
use url:: Url ;
35
36
36
37
pub struct Http2Client {
37
- pub client : AsyncRefCell < h2:: client:: SendRequest < Bytes > > ,
38
+ pub client : AsyncRefCell < h2:: client:: SendRequest < BufView > > ,
38
39
pub url : Url ,
39
40
}
40
41
@@ -46,7 +47,7 @@ impl Resource for Http2Client {
46
47
47
48
#[ derive( Debug ) ]
48
49
pub struct Http2ClientConn {
49
- pub conn : AsyncRefCell < h2:: client:: Connection < NetworkStream > > ,
50
+ pub conn : AsyncRefCell < h2:: client:: Connection < NetworkStream , BufView > > ,
50
51
cancel_handle : CancelHandle ,
51
52
}
52
53
@@ -63,7 +64,7 @@ impl Resource for Http2ClientConn {
63
64
#[ derive( Debug ) ]
64
65
pub struct Http2ClientStream {
65
66
pub response : AsyncRefCell < h2:: client:: ResponseFuture > ,
66
- pub stream : AsyncRefCell < h2:: SendStream < Bytes > > ,
67
+ pub stream : AsyncRefCell < h2:: SendStream < BufView > > ,
67
68
}
68
69
69
70
impl Resource for Http2ClientStream {
@@ -89,7 +90,7 @@ impl Resource for Http2ClientResponseBody {
89
90
90
91
#[ derive( Debug ) ]
91
92
pub struct Http2ServerConnection {
92
- pub conn : AsyncRefCell < h2:: server:: Connection < NetworkStream , Bytes > > ,
93
+ pub conn : AsyncRefCell < h2:: server:: Connection < NetworkStream , BufView > > ,
93
94
}
94
95
95
96
impl Resource for Http2ServerConnection {
@@ -99,7 +100,7 @@ impl Resource for Http2ServerConnection {
99
100
}
100
101
101
102
pub struct Http2ServerSendResponse {
102
- pub send_response : AsyncRefCell < h2:: server:: SendResponse < Bytes > > ,
103
+ pub send_response : AsyncRefCell < h2:: server:: SendResponse < BufView > > ,
103
104
}
104
105
105
106
impl Resource for Http2ServerSendResponse {
@@ -123,7 +124,8 @@ pub async fn op_http2_connect(
123
124
124
125
let url = Url :: parse ( & url) ?;
125
126
126
- let ( client, conn) = h2:: client:: handshake ( network_stream) . await ?;
127
+ let ( client, conn) =
128
+ h2:: client:: Builder :: new ( ) . handshake ( network_stream) . await ?;
127
129
let mut state = state. borrow_mut ( ) ;
128
130
let client_rid = state. resource_table . add ( Http2Client {
129
131
client : AsyncRefCell :: new ( client) ,
@@ -145,7 +147,7 @@ pub async fn op_http2_listen(
145
147
let stream =
146
148
take_network_stream_resource ( & mut state. borrow_mut ( ) . resource_table , rid) ?;
147
149
148
- let conn = h2:: server:: handshake ( stream) . await ?;
150
+ let conn = h2:: server:: Builder :: new ( ) . handshake ( stream) . await ?;
149
151
Ok (
150
152
state
151
153
. borrow_mut ( )
@@ -349,7 +351,7 @@ pub async fn op_http2_client_send_data(
349
351
let mut stream = RcRef :: map ( & resource, |r| & r. stream ) . borrow_mut ( ) . await ;
350
352
351
353
// TODO(bartlomieju): handle end of stream
352
- stream. send_data ( bytes :: Bytes :: from ( data) , false ) ?;
354
+ stream. send_data ( data. to_vec ( ) . into ( ) , false ) ?;
353
355
Ok ( ( ) )
354
356
}
355
357
@@ -365,7 +367,7 @@ pub async fn op_http2_client_end_stream(
365
367
let mut stream = RcRef :: map ( & resource, |r| & r. stream ) . borrow_mut ( ) . await ;
366
368
367
369
// TODO(bartlomieju): handle end of stream
368
- stream. send_data ( bytes :: Bytes :: from ( vec ! [ ] ) , true ) ?;
370
+ stream. send_data ( BufView :: empty ( ) , true ) ?;
369
371
Ok ( ( ) )
370
372
}
371
373
0 commit comments