@@ -260,6 +260,47 @@ void testRequestBody(Client client) {
260260 expect (serverReceivedBody.codeUnits, < int > []);
261261 });
262262
263+ test ('client.send() with persistentConnection' , () async {
264+ // Do five requests to verify that the connection persistance logic is
265+ // correct.
266+ for (var i = 0 ; i < 5 ; ++ i) {
267+ final request = Request ('POST' , Uri .http (host, '' ))
268+ ..headers['Content-Type' ] = 'text/plain; charset=utf-8'
269+ ..persistentConnection = true
270+ ..body = 'Hello World $i ' ;
271+
272+ final response = await client.send (request);
273+ expect (response.statusCode, 200 );
274+
275+ final serverReceivedContentType = await httpServerQueue.next;
276+ final serverReceivedBody = await httpServerQueue.next as String ;
277+
278+ expect (serverReceivedContentType, ['text/plain; charset=utf-8' ]);
279+ expect (serverReceivedBody, 'Hello World $i ' );
280+ }
281+ });
282+
283+ test ('client.send() with persistentConnection and body >64K' , () async {
284+ // 64KiB is special for the HTTP network API:
285+ // https://fetch.spec.whatwg.org/#http-network-or-cache-fetch
286+ // See https://github.com/dart-lang/http/issues/977
287+ final body = '' .padLeft (64 * 1024 , 'XYZ' );
288+
289+ final request = Request ('POST' , Uri .http (host, '' ))
290+ ..headers['Content-Type' ] = 'text/plain; charset=utf-8'
291+ ..persistentConnection = true
292+ ..body = body;
293+
294+ final response = await client.send (request);
295+ expect (response.statusCode, 200 );
296+
297+ final serverReceivedContentType = await httpServerQueue.next;
298+ final serverReceivedBody = await httpServerQueue.next as String ;
299+
300+ expect (serverReceivedContentType, ['text/plain; charset=utf-8' ]);
301+ expect (serverReceivedBody, body);
302+ });
303+
263304 test ('client.send() GET with non-empty stream' , () async {
264305 final request = StreamedRequest ('GET' , Uri .http (host, '' ));
265306 request.headers['Content-Type' ] = 'image/png' ;
0 commit comments