File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -1459,8 +1459,8 @@ public function isMethodSafe()
1459
1459
*/
1460
1460
public function getContent ($ asResource = false )
1461
1461
{
1462
- if (false === $ this ->content || (true === $ asResource && null !== $ this ->content )) {
1463
- throw new \LogicException ('getContent() can only be called once when using the resource return type. ' );
1462
+ if (PHP_VERSION_ID < 50600 && ( false === $ this ->content || (true === $ asResource && null !== $ this ->content ) )) {
1463
+ throw new \LogicException ('getContent() can only be called once when using the resource return type and PHP below 5.6 . ' );
1464
1464
}
1465
1465
1466
1466
if (true === $ asResource ) {
Original file line number Diff line number Diff line change @@ -929,11 +929,40 @@ public function testGetContentReturnsResource()
929
929
*/
930
930
public function testGetContentCantBeCalledTwiceWithResources ($ first , $ second )
931
931
{
932
+ if (PHP_VERSION_ID >= 50600 ) {
933
+ $ this ->markTestSkipped ('PHP >= 5.6 allows to open php://input several times. ' );
934
+ }
935
+
932
936
$ req = new Request ();
933
937
$ req ->getContent ($ first );
934
938
$ req ->getContent ($ second );
935
939
}
936
940
941
+ /**
942
+ *
943
+ * @dataProvider getContentCantBeCalledTwiceWithResourcesProvider
944
+ */
945
+ public function testGetContentCanBeCalledTwiceWithResources ($ first , $ second )
946
+ {
947
+ if (PHP_VERSION_ID < 50600 ) {
948
+ $ this ->markTestSkipped ('PHP < 5.6 does not allow to open php://input several times. ' );
949
+ }
950
+
951
+ $ req = new Request ();
952
+ $ a = $ req ->getContent ($ first );
953
+ $ b = $ req ->getContent ($ second );
954
+
955
+ if ($ first ) {
956
+ $ a = stream_get_contents ($ a );
957
+ }
958
+
959
+ if ($ second ) {
960
+ $ b = stream_get_contents ($ b );
961
+ }
962
+
963
+ $ this ->assertEquals ($ a , $ b );
964
+ }
965
+
937
966
public function getContentCantBeCalledTwiceWithResourcesProvider ()
938
967
{
939
968
return array (
You can’t perform that action at this time.
0 commit comments