@@ -35,6 +35,10 @@ const MAX_DATAGRAM_SIZE: usize = 1350;
3535
3636const HTTP_REQ_STREAM_ID : u64 = 4 ;
3737
38+ struct TestData {
39+ num_messages : u8 ,
40+ }
41+
3842fn main ( ) {
3943 let mut buf = [ 0 ; 65535 ] ;
4044 let mut out = [ 0 ; MAX_DATAGRAM_SIZE ] ;
@@ -96,8 +100,8 @@ fn main() {
96100 config. set_initial_max_data ( 10_000_000 ) ;
97101 config. set_initial_max_stream_data_bidi_local ( 1_000_000 ) ;
98102 config. set_initial_max_stream_data_bidi_remote ( 1_000_000 ) ;
99- config. set_initial_max_streams_bidi ( 100 ) ;
100- config. set_initial_max_streams_uni ( 100 ) ;
103+ config. set_initial_max_streams_bidi ( 10000 ) ;
104+ config. set_initial_max_streams_uni ( 10000 ) ;
101105 config. set_disable_active_migration ( true ) ;
102106
103107 // Generate a random source connection ID for the connection.
@@ -198,46 +202,64 @@ fn main() {
198202
199203 // Send an HTTP request as soon as the connection is established.
200204 if conn. is_established ( ) && !req_sent {
201- info ! ( "sending HTTP request for {}" , url. path( ) ) ;
202-
203- let req = format ! ( "GET {}\r \n " , url. path( ) ) ;
204- conn. stream_send ( HTTP_REQ_STREAM_ID , req. as_bytes ( ) , true )
205- . unwrap ( ) ;
205+ println ! ( "Init data" ) ;
206+ // init application data
207+ match conn. stream_send ( 0 , b"" , false ) {
208+ Ok ( _) => { } ,
209+ Err ( quiche:: Error :: Done ) => { } ,
210+ Err ( e) => {
211+ error ! ( "{} stream send failed {:?}" , conn. trace_id( ) , e) ;
212+ return ;
213+ } ,
214+ } ;
215+ match conn. stream_init_application_data ( 0 , TestData { num_messages : 0 } ) {
216+ Ok ( _) => { } ,
217+ Err ( quiche:: Error :: Done ) => { } ,
218+ Err ( e) => {
219+ error ! ( "{} stream init failed {:?}" , conn. trace_id( ) , e) ;
220+ return ;
221+ } ,
222+ } ;
206223
207224 req_sent = true ;
208225 }
209226
210227 // Process all readable streams.
211228 for s in conn. readable ( ) {
212229 while let Ok ( ( read, fin) ) = conn. stream_recv ( s, & mut buf) {
213- debug ! ( "received {} bytes" , read) ;
230+ println ! ( "received {} bytes" , read) ;
214231
215232 let stream_buf = & buf[ ..read] ;
216233
217- debug ! (
234+ println ! (
218235 "stream {} has {} bytes (fin? {})" ,
219236 s,
220237 stream_buf. len( ) ,
221238 fin
222239 ) ;
223240
224- print ! ( "{}" , unsafe {
241+ println ! ( "{}" , unsafe {
225242 std:: str :: from_utf8_unchecked( stream_buf)
226243 } ) ;
227244
228- // The server reported that it has no more data to send, which
229- // we got the full response. Close the connection.
230- if s == HTTP_REQ_STREAM_ID && fin {
231- info ! (
232- "response received in {:?}, closing..." ,
233- req_start. elapsed( )
234- ) ;
235-
236- conn. close ( true , 0x00 , b"kthxbye" ) . unwrap ( ) ;
237- }
238245 }
239246 }
240247
248+ for s in conn. writable ( ) {
249+ println ! ( "Writing stream {}" , s) ;
250+ let written = match conn. stream_send ( s, b"Hello!" , true ) {
251+ Ok ( v) => v,
252+
253+ Err ( quiche:: Error :: Done ) => 0 ,
254+
255+ Err ( e) => {
256+ error ! ( "{} stream send failed {:?}" , conn. trace_id( ) , e) ;
257+ return ;
258+ } ,
259+ } ;
260+ println ! ( "Written {} bytes" , written) ;
261+ }
262+
241263 // Generate outgoing QUIC packets and send them on the UDP socket, until
242264 // quiche reports that there are no more packets to be sent.
243265 loop {
0 commit comments