File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,15 @@ where
202202 return Ok ( Async :: NotReady ) ;
203203 }
204204 } ;
205- assert ! ( self . conn. write_body( Some ( chunk) ) ?. is_ready( ) ) ;
205+
206+ if self . conn . can_write_body ( ) {
207+ assert ! ( self . conn. write_body( Some ( chunk) ) ?. is_ready( ) ) ;
208+ // This allows when chunk is `None`, or `Some([])`.
209+ } else if chunk. as_ref ( ) . len ( ) == 0 {
210+ // ok
211+ } else {
212+ warn ! ( "unexpected chunk when body cannot write" ) ;
213+ }
206214 } else {
207215 return Ok ( Async :: NotReady ) ;
208216 }
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ macro_rules! test {
6565
6666 let res = test! {
6767 INNER ;
68+ name: $name,
6869 core: & mut core,
6970 server:
7071 expected: $server_expected,
@@ -115,6 +116,7 @@ macro_rules! test {
115116
116117 let err = test! {
117118 INNER ;
119+ name: $name,
118120 core: & mut core,
119121 server:
120122 expected: $server_expected,
@@ -135,6 +137,7 @@ macro_rules! test {
135137
136138 (
137139 INNER ;
140+ name: $name: ident,
138141 core: $core: expr,
139142 server:
140143 expected: $server_expected: expr,
@@ -299,6 +302,33 @@ test! {
299302 body: None ,
300303}
301304
305+ test ! {
306+ name: client_post_empty,
307+
308+ server:
309+ expected: "\
310+ POST /empty HTTP/1.1\r \n \
311+ Host: {addr}\r \n \
312+ Content-Length: 0\r \n \
313+ \r \n \
314+ ",
315+ reply: REPLY_OK ,
316+
317+ client:
318+ request:
319+ method: Post ,
320+ url: "http://{addr}/empty" ,
321+ headers: [
322+ ContentLength ( 0 ) ,
323+ ] ,
324+ body: Some ( "" ) ,
325+ proxy: false ,
326+ response:
327+ status: Ok ,
328+ headers: [ ] ,
329+ body: None ,
330+ }
331+
302332test ! {
303333 name: client_http_proxy,
304334
You can’t perform that action at this time.
0 commit comments