File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Contracts \HttpClient \Exception ;
13+
14+ /**
15+ * When an idle timeout occurs.
16+ *
17+ * @author Nicolas Grekas <p@tchwork.com>
18+ */
19+ interface TimeoutExceptionInterface extends TransportExceptionInterface
20+ {
21+ }
Original file line number Diff line number Diff line change 116116 echo '<1> ' ;
117117 @ob_flush ();
118118 flush ();
119- usleep (500000 );
119+ usleep (600000 );
120120 echo '<2> ' ;
121121 exit ;
122122
Original file line number Diff line number Diff line change 1414use PHPUnit \Framework \TestCase ;
1515use Symfony \Contracts \HttpClient \Exception \ClientExceptionInterface ;
1616use Symfony \Contracts \HttpClient \Exception \RedirectionExceptionInterface ;
17+ use Symfony \Contracts \HttpClient \Exception \TimeoutExceptionInterface ;
1718use Symfony \Contracts \HttpClient \Exception \TransportExceptionInterface ;
1819use Symfony \Contracts \HttpClient \HttpClientInterface ;
1920
@@ -739,9 +740,35 @@ public function testTimeoutOnAccess()
739740 $ response ->getHeaders ();
740741 }
741742
742- public function testTimeoutOnStream ()
743+ public function testTimeoutIsNotAFatalError ()
743744 {
744745 usleep (300000 ); // wait for the previous test to release the server
746+ $ client = $ this ->getHttpClient (__FUNCTION__ );
747+ $ response = $ client ->request ('GET ' , 'http://localhost:8057/timeout-body ' , [
748+ 'timeout ' => 0.3 ,
749+ ]);
750+
751+ try {
752+ $ response ->getContent ();
753+ $ this ->fail (TimeoutExceptionInterface::class.' expected ' );
754+ } catch (TimeoutExceptionInterface $ e ) {
755+ }
756+
757+ for ($ i = 0 ; $ i < 10 ; ++$ i ) {
758+ try {
759+ $ this ->assertSame ('<1><2> ' , $ response ->getContent ());
760+ break ;
761+ } catch (TimeoutExceptionInterface $ e ) {
762+ }
763+ }
764+
765+ if (10 === $ i ) {
766+ throw $ e ;
767+ }
768+ }
769+
770+ public function testTimeoutOnStream ()
771+ {
745772 $ client = $ this ->getHttpClient (__FUNCTION__ );
746773 $ response = $ client ->request ('GET ' , 'http://localhost:8057/timeout-body ' );
747774
You can’t perform that action at this time.
0 commit comments