File tree 2 files changed +39
-1
lines changed
2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,15 @@ where
202
202
return Ok ( Async :: NotReady ) ;
203
203
}
204
204
} ;
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
+ }
206
214
} else {
207
215
return Ok ( Async :: NotReady ) ;
208
216
}
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ macro_rules! test {
65
65
66
66
let res = test! {
67
67
INNER ;
68
+ name: $name,
68
69
core: & mut core,
69
70
server:
70
71
expected: $server_expected,
@@ -115,6 +116,7 @@ macro_rules! test {
115
116
116
117
let err = test! {
117
118
INNER ;
119
+ name: $name,
118
120
core: & mut core,
119
121
server:
120
122
expected: $server_expected,
@@ -135,6 +137,7 @@ macro_rules! test {
135
137
136
138
(
137
139
INNER ;
140
+ name: $name: ident,
138
141
core: $core: expr,
139
142
server:
140
143
expected: $server_expected: expr,
@@ -299,6 +302,33 @@ test! {
299
302
body: None ,
300
303
}
301
304
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
+
302
332
test ! {
303
333
name: client_http_proxy,
304
334
You can’t perform that action at this time.
0 commit comments