@@ -373,6 +373,7 @@ def write_bytes(self, request, reader):
373373
374374 try :
375375 if asyncio .iscoroutine (self .body ):
376+ request .transport .set_tcp_nodelay (True )
376377 exc = None
377378 value = None
378379 stream = self .body
@@ -407,12 +408,14 @@ def write_bytes(self, request, reader):
407408 type (result ))
408409
409410 elif isinstance (self .body , asyncio .StreamReader ):
411+ request .transport .set_tcp_nodelay (True )
410412 chunk = yield from self .body .read (streams .DEFAULT_LIMIT )
411413 while chunk :
412414 yield from request .write (chunk , drain = True )
413415 chunk = yield from self .body .read (streams .DEFAULT_LIMIT )
414416
415417 elif isinstance (self .body , streams .DataQueue ):
418+ request .transport .set_tcp_nodelay (True )
416419 while True :
417420 try :
418421 chunk = yield from self .body .read ()
@@ -427,20 +430,24 @@ def write_bytes(self, request, reader):
427430 while chunk :
428431 request .write (chunk )
429432 chunk = self .body .read (self .chunked )
433+ request .transport .set_tcp_nodelay (True )
430434
431435 else :
432436 if isinstance (self .body , (bytes , bytearray )):
433437 self .body = (self .body ,)
434438
435439 for chunk in self .body :
436440 request .write (chunk )
441+ request .transport .set_tcp_nodelay (True )
442+
437443 except Exception as exc :
438444 new_exc = aiohttp .ClientRequestError (
439445 'Can not write request body for %s' % self .url )
440446 new_exc .__context__ = exc
441447 new_exc .__cause__ = exc
442448 reader .set_exception (new_exc )
443449 else :
450+ assert request .transport .tcp_nodelay
444451 try :
445452 ret = request .write_eof ()
446453 # NB: in asyncio 3.4.1+ StreamWriter.drain() is coroutine
@@ -458,6 +465,7 @@ def write_bytes(self, request, reader):
458465 self ._writer = None
459466
460467 def send (self , writer , reader ):
468+ writer .set_tcp_cork (True )
461469 request = aiohttp .Request (writer , self .method , self .path , self .version )
462470
463471 if self .compress :
0 commit comments