@@ -58,6 +58,7 @@ public function testGetRequest()
58
58
$ this ->assertSame (['application/json ' ], $ headers ['content-type ' ]);
59
59
60
60
$ body = json_decode ($ response ->getContent (), true );
61
+ $ this ->assertSame ($ body , $ response ->toArray ());
61
62
62
63
$ this ->assertSame ('HTTP/1.1 ' , $ body ['SERVER_PROTOCOL ' ]);
63
64
$ this ->assertSame ('/ ' , $ body ['REQUEST_URI ' ]);
@@ -79,7 +80,7 @@ public function testNonBufferedGetRequest()
79
80
'headers ' => ['Foo ' => 'baR ' ],
80
81
]);
81
82
82
- $ body = json_decode ( $ response ->getContent (), true );
83
+ $ body = $ response ->toArray ( );
83
84
$ this ->assertSame ('baR ' , $ body ['HTTP_FOO ' ]);
84
85
85
86
$ this ->expectException (TransportExceptionInterface::class);
@@ -106,7 +107,7 @@ public function testHttpVersion()
106
107
$ this ->assertSame (200 , $ response ->getStatusCode ());
107
108
$ this ->assertSame ('HTTP/1.0 200 OK ' , $ response ->getInfo ('raw_headers ' )[0 ]);
108
109
109
- $ body = json_decode ( $ response ->getContent (), true );
110
+ $ body = $ response ->toArray ( );
110
111
111
112
$ this ->assertSame ('HTTP/1.0 ' , $ body ['SERVER_PROTOCOL ' ]);
112
113
$ this ->assertSame ('GET ' , $ body ['REQUEST_METHOD ' ]);
@@ -203,7 +204,7 @@ public function testInlineAuth()
203
204
$ client = $ this ->getHttpClient ();
204
205
$ response = $ client ->request ('GET ' , 'http://foo:bar%3Dbar@localhost:8057 ' );
205
206
206
- $ body = json_decode ( $ response ->getContent (), true );
207
+ $ body = $ response ->toArray ( );
207
208
208
209
$ this ->assertSame ('foo ' , $ body ['PHP_AUTH_USER ' ]);
209
210
$ this ->assertSame ('bar=bar ' , $ body ['PHP_AUTH_PW ' ]);
@@ -219,7 +220,7 @@ public function testRedirects()
219
220
},
220
221
]);
221
222
222
- $ body = json_decode ( $ response ->getContent (), true );
223
+ $ body = $ response ->toArray ( );
223
224
$ this ->assertSame ('GET ' , $ body ['REQUEST_METHOD ' ]);
224
225
$ this ->assertSame ('Basic Zm9vOmJhcg== ' , $ body ['HTTP_AUTHORIZATION ' ]);
225
226
$ this ->assertSame ('http://localhost:8057/ ' , $ response ->getInfo ('url ' ));
@@ -250,7 +251,8 @@ public function testRelativeRedirects()
250
251
$ client = $ this ->getHttpClient ();
251
252
$ response = $ client ->request ('GET ' , 'http://localhost:8057/302/relative ' );
252
253
253
- $ body = json_decode ($ response ->getContent (), true );
254
+ $ body = $ response ->toArray ();
255
+
254
256
$ this ->assertSame ('/ ' , $ body ['REQUEST_URI ' ]);
255
257
$ this ->assertNull ($ response ->getInfo ('redirect_url ' ));
256
258
@@ -279,7 +281,7 @@ public function testRedirect307()
279
281
'body ' => 'foo=bar ' ,
280
282
]);
281
283
282
- $ body = json_decode ( $ response ->getContent (), true );
284
+ $ body = $ response ->toArray ( );
283
285
284
286
$ this ->assertSame (['foo ' => 'bar ' , 'REQUEST_METHOD ' => 'POST ' ], $ body );
285
287
}
@@ -388,7 +390,7 @@ public function testOnProgress()
388
390
'on_progress ' => function (...$ state ) use (&$ steps ) { $ steps [] = $ state ; },
389
391
]);
390
392
391
- $ body = json_decode ( $ response ->getContent (), true );
393
+ $ body = $ response ->toArray ( );
392
394
393
395
$ this ->assertSame (['foo ' => '0123456789 ' , 'REQUEST_METHOD ' => 'POST ' ], $ body );
394
396
$ this ->assertSame ([0 , 0 ], \array_slice ($ steps [0 ], 0 , 2 ));
@@ -405,7 +407,7 @@ public function testPostArray()
405
407
'body ' => ['foo ' => 'bar ' ],
406
408
]);
407
409
408
- $ this ->assertSame (['foo ' => 'bar ' , 'REQUEST_METHOD ' => 'POST ' ], json_decode ( $ response ->getContent (), true ));
410
+ $ this ->assertSame (['foo ' => 'bar ' , 'REQUEST_METHOD ' => 'POST ' ], $ response ->toArray ( ));
409
411
}
410
412
411
413
public function testPostResource ()
@@ -420,7 +422,7 @@ public function testPostResource()
420
422
'body ' => $ h ,
421
423
]);
422
424
423
- $ body = json_decode ( $ response ->getContent (), true );
425
+ $ body = $ response ->toArray ( );
424
426
425
427
$ this ->assertSame (['foo ' => '0123456789 ' , 'REQUEST_METHOD ' => 'POST ' ], $ body );
426
428
}
@@ -438,7 +440,7 @@ public function testPostCallback()
438
440
},
439
441
]);
440
442
441
- $ this ->assertSame (['foo ' => '0123456789 ' , 'REQUEST_METHOD ' => 'POST ' ], json_decode ( $ response ->getContent (), true ));
443
+ $ this ->assertSame (['foo ' => '0123456789 ' , 'REQUEST_METHOD ' => 'POST ' ], $ response ->toArray ( ));
442
444
}
443
445
444
446
public function testOnProgressCancel ()
@@ -581,15 +583,15 @@ public function testProxy()
581
583
'proxy ' => 'http://localhost:8057 ' ,
582
584
]);
583
585
584
- $ body = json_decode ( $ response ->getContent (), true );
586
+ $ body = $ response ->toArray ( );
585
587
$ this ->assertSame ('localhost:8057 ' , $ body ['HTTP_HOST ' ]);
586
588
$ this ->assertRegexp ('#^http://(localhost|127\.0\.0\.1):8057/$# ' , $ body ['REQUEST_URI ' ]);
587
589
588
590
$ response = $ client ->request ('GET ' , 'http://localhost:8057/ ' , [
589
591
'proxy ' => 'http://foo:b%3Dar@localhost:8057 ' ,
590
592
]);
591
593
592
- $ body = json_decode ( $ response ->getContent (), true );
594
+ $ body = $ response ->toArray ( );
593
595
$ this ->assertSame ('Basic Zm9vOmI9YXI= ' , $ body ['HTTP_PROXY_AUTHORIZATION ' ]);
594
596
}
595
597
@@ -603,7 +605,7 @@ public function testNoProxy()
603
605
'proxy ' => 'http://localhost:8057 ' ,
604
606
]);
605
607
606
- $ body = json_decode ( $ response ->getContent (), true );
608
+ $ body = $ response ->toArray ( );
607
609
608
610
$ this ->assertSame ('HTTP/1.1 ' , $ body ['SERVER_PROTOCOL ' ]);
609
611
$ this ->assertSame ('/ ' , $ body ['REQUEST_URI ' ]);
@@ -629,7 +631,7 @@ public function testAutoEncodingRequest()
629
631
$ this ->assertSame (['Accept-Encoding ' ], $ headers ['vary ' ]);
630
632
$ this ->assertContains ('gzip ' , $ headers ['content-encoding ' ][0 ]);
631
633
632
- $ body = json_decode ( $ response ->getContent (), true );
634
+ $ body = $ response ->toArray ( );
633
635
634
636
$ this ->assertContains ('gzip ' , $ body ['HTTP_ACCEPT_ENCODING ' ]);
635
637
}
@@ -652,7 +654,7 @@ public function testQuery()
652
654
'query ' => ['b ' => 'b ' ],
653
655
]);
654
656
655
- $ body = json_decode ( $ response ->getContent (), true );
657
+ $ body = $ response ->toArray ( );
656
658
$ this ->assertSame ('GET ' , $ body ['REQUEST_METHOD ' ]);
657
659
$ this ->assertSame ('/?a=a&b=b ' , $ body ['REQUEST_URI ' ]);
658
660
}
@@ -673,10 +675,9 @@ public function testUserlandEncodingRequest()
673
675
$ this ->assertContains ('gzip ' , $ headers ['content-encoding ' ][0 ]);
674
676
675
677
$ body = $ response ->getContent ();
676
-
677
678
$ this ->assertSame ("\x1F" , $ body [0 ]);
678
- $ body = json_decode (gzdecode ($ body ), true );
679
679
680
+ $ body = json_decode (gzdecode ($ body ), true );
680
681
$ this ->assertSame ('gzip ' , $ body ['HTTP_ACCEPT_ENCODING ' ]);
681
682
}
682
683
0 commit comments