File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -117,8 +117,11 @@ impl Sender {
117
117
}
118
118
119
119
// Write the data section, and end.
120
- let msg = format ! ( "data:{}\n \n " , data) ;
121
- self . inner_send ( msg) . await ?;
120
+ for line in data. lines ( ) {
121
+ let msg = format ! ( "data:{}\n " , line) ;
122
+ self . inner_send ( msg) . await ?;
123
+ }
124
+ self . inner_send ( "\n " ) . await ?;
122
125
123
126
Ok ( ( ) )
124
127
}
Original file line number Diff line number Diff line change @@ -95,6 +95,17 @@ async fn encode_retry() -> http_types::Result<()> {
95
95
Ok ( ( ) )
96
96
}
97
97
98
+ #[ async_std:: test]
99
+ async fn encode_multiline_message ( ) -> http_types:: Result < ( ) > {
100
+ let ( sender, encoder) = encode ( ) ;
101
+ task:: spawn ( async move { sender. send ( "cats" , "chashu\n nori" , None ) . await } ) ;
102
+
103
+ let mut reader = decode ( BufReader :: new ( encoder) ) ;
104
+ let event = reader. next ( ) . await . unwrap ( ) ?;
105
+ assert_message ( & event, "cats" , "chashu\n nori" , None ) ;
106
+ Ok ( ( ) )
107
+ }
108
+
98
109
#[ async_std:: test]
99
110
async fn dropping_encoder ( ) -> http_types:: Result < ( ) > {
100
111
let ( sender, encoder) = encode ( ) ;
You can’t perform that action at this time.
0 commit comments