File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -441,7 +441,8 @@ where I: AsyncRead + AsyncWrite,
441
441
} )
442
442
}
443
443
} ) ;
444
- } else if chunk. is_none ( ) {
444
+ // This allows when chunk is `None`, or `Some([])`.
445
+ } else if chunk. as_ref ( ) . map ( |c| c. as_ref ( ) . len ( ) ) . unwrap_or ( 0 ) == 0 {
445
446
return Ok ( AsyncSink :: Ready ) ;
446
447
} else {
447
448
Frame : : Body { chunk : chunk }
@@ -932,4 +933,15 @@ mod tests {
932
933
933
934
assert ! ( conn. state. is_write_closed( ) ) ;
934
935
}
936
+
937
+ #[ test]
938
+ fn test_conn_write_empty_chunk ( ) {
939
+ let io = AsyncIo :: new_buf ( vec ! [ ] , 0 ) ;
940
+ let mut conn = Conn :: < _ , http:: Chunk , ServerTransaction > :: new ( io, Default :: default ( ) ) ;
941
+ conn. state . writing = Writing :: KeepAlive ;
942
+
943
+ assert ! ( conn. start_send( Frame :: Body { chunk: None } ) . unwrap( ) . is_ready( ) ) ;
944
+ assert ! ( conn. start_send( Frame :: Body { chunk: Some ( Vec :: new( ) . into( ) ) } ) . unwrap( ) . is_ready( ) ) ;
945
+ conn. start_send ( Frame :: Body { chunk : Some ( vec ! [ b'a' ] . into ( ) ) } ) . unwrap_err ( ) ;
946
+ }
935
947
}
You can’t perform that action at this time.
0 commit comments