@@ -165,8 +165,6 @@ public function testItIsEmptyAfterReset()
165
165
}
166
166
167
167
/**
168
- * @requires extension openssl
169
- *
170
168
* @dataProvider provideCurlRequests
171
169
*/
172
170
public function testItGeneratesCurlCommandsAsExpected (array $ request , string $ expectedCurlCommand )
@@ -177,7 +175,9 @@ public function testItGeneratesCurlCommandsAsExpected(array $request, string $ex
177
175
$ collectedData = $ sut ->getClients ();
178
176
self ::assertCount (1 , $ collectedData ['http_client ' ]['traces ' ]);
179
177
$ curlCommand = $ collectedData ['http_client ' ]['traces ' ][0 ]['curlCommand ' ];
180
- self ::assertEquals (sprintf ($ expectedCurlCommand , '\\' === \DIRECTORY_SEPARATOR ? '" ' : "' " ), $ curlCommand );
178
+
179
+ $ isWindows = '\\' === \DIRECTORY_SEPARATOR ;
180
+ self ::assertEquals (sprintf ($ expectedCurlCommand , $ isWindows ? '" ' : "' " , $ isWindows ? '' : "' " ), $ curlCommand );
181
181
}
182
182
183
183
public static function provideCurlRequests (): iterable
@@ -236,19 +236,19 @@ public static function provideCurlRequests(): iterable
236
236
'method ' => 'POST ' ,
237
237
'url ' => 'http://localhost:8057/json ' ,
238
238
'options ' => [
239
- 'body ' => 'foobarbaz ' ,
239
+ 'body ' => 'foo bar baz ' ,
240
240
],
241
241
],
242
242
'curl \\
243
243
--compressed \\
244
244
--request POST \\
245
245
--url %1$shttp://localhost:8057/json%1$s \\
246
246
--header %1$sAccept: */*%1$s \\
247
- --header %1$sContent-Length: 9 %1$s \\
247
+ --header %1$sContent-Length: 11 %1$s \\
248
248
--header %1$sContent-Type: application/x-www-form-urlencoded%1$s \\
249
249
--header %1$sAccept-Encoding: gzip%1$s \\
250
250
--header %1$sUser-Agent: Symfony HttpClient (Native)%1$s \\
251
- --data %1$sfoobarbaz %1$s ' ,
251
+ --data-raw %1$sfoo bar baz %1$s ' ,
252
252
];
253
253
yield 'POST with array body ' => [
254
254
[
@@ -286,7 +286,7 @@ public function __toString(): string
286
286
--header %1$sContent-Length: 211%1$s \\
287
287
--header %1$sAccept-Encoding: gzip%1$s \\
288
288
--header %1$sUser-Agent: Symfony HttpClient (Native)%1$s \\
289
- --data %1 $sfoo=fooval%1 $s --data %1 $sbar=barval%1 $s --data %1 $sbaz=bazval%1 $s --data %1 $sfoobar[baz]=bazval%1 $s --data %1 $sfoobar[qux]=quxval%1 $s --data %1 $sbazqux[0]=bazquxval1%1 $s --data %1 $sbazqux[1]=bazquxval2%1 $s --data %1 $sobject[fooprop]=foopropval%1 $s --data %1 $sobject[barprop]=barpropval%1 $s --data %1 $stostring=tostringval%1 $s ' ,
289
+ --data-raw %2 $sfoo=fooval%2 $s --data-raw %2 $sbar=barval%2 $s --data-raw %2 $sbaz=bazval%2 $s --data-raw %2 $sfoobar[baz]=bazval%2 $s --data-raw %2 $sfoobar[qux]=quxval%2 $s --data-raw %2 $sbazqux[0]=bazquxval1%2 $s --data-raw %2 $sbazqux[1]=bazquxval2%2 $s --data-raw %2 $sobject[fooprop]=foopropval%2 $s --data-raw %2 $sobject[barprop]=barpropval%2 $s --data-raw %2 $stostring=tostringval%2 $s ' ,
290
290
];
291
291
292
292
// escapeshellarg on Windows replaces double quotes & percent signs with spaces
@@ -337,14 +337,11 @@ public function __toString(): string
337
337
--header %1$sContent-Length: 120%1$s \\
338
338
--header %1$sAccept-Encoding: gzip%1$s \\
339
339
--header %1$sUser-Agent: Symfony HttpClient (Native)%1$s \\
340
- --data %1$s{"foo":{"bar":"baz","qux":[1.1,1.0],"fred":["\u003Cfoo\u003E","\u0027bar\u0027","\u0022baz\u0022","\u0026blong\u0026"]}}%1$s ' ,
340
+ --data-raw %1$s{"foo":{"bar":"baz","qux":[1.1,1.0],"fred":["\u003Cfoo\u003E","\u0027bar\u0027","\u0022baz\u0022","\u0026blong\u0026"]}}%1$s ' ,
341
341
];
342
342
}
343
343
}
344
344
345
- /**
346
- * @requires extension openssl
347
- */
348
345
public function testItDoesNotFollowRedirectionsWhenGeneratingCurlCommands ()
349
346
{
350
347
$ sut = new HttpClientDataCollector ();
@@ -372,9 +369,6 @@ public function testItDoesNotFollowRedirectionsWhenGeneratingCurlCommands()
372
369
);
373
370
}
374
371
375
- /**
376
- * @requires extension openssl
377
- */
378
372
public function testItDoesNotGeneratesCurlCommandsForUnsupportedBodyType ()
379
373
{
380
374
$ sut = new HttpClientDataCollector ();
@@ -394,40 +388,34 @@ public function testItDoesNotGeneratesCurlCommandsForUnsupportedBodyType()
394
388
self ::assertNull ($ curlCommand );
395
389
}
396
390
397
- /**
398
- * @requires extension openssl
399
- */
400
- public function testItDoesNotGeneratesCurlCommandsForNotEncodableBody ()
391
+ public function testItDoesGenerateCurlCommandsForBigData ()
401
392
{
402
393
$ sut = new HttpClientDataCollector ();
403
394
$ sut ->registerClient ('http_client ' , $ this ->httpClientThatHasTracedRequests ([
404
395
[
405
396
'method ' => 'POST ' ,
406
397
'url ' => 'http://localhost:8057/json ' ,
407
398
'options ' => [
408
- 'body ' => "\0" ,
399
+ 'body ' => str_repeat ( ' 1 ' , 257000 ) ,
409
400
],
410
401
],
411
402
]));
412
403
$ sut ->lateCollect ();
413
404
$ collectedData = $ sut ->getClients ();
414
405
self ::assertCount (1 , $ collectedData ['http_client ' ]['traces ' ]);
415
406
$ curlCommand = $ collectedData ['http_client ' ]['traces ' ][0 ]['curlCommand ' ];
416
- self ::assertNull ($ curlCommand );
407
+ self ::assertNotNull ($ curlCommand );
417
408
}
418
409
419
- /**
420
- * @requires extension openssl
421
- */
422
- public function testItDoesNotGeneratesCurlCommandsForTooBigData ()
410
+ public function testItDoesNotGeneratesCurlCommandsForUploadedFiles ()
423
411
{
424
412
$ sut = new HttpClientDataCollector ();
425
413
$ sut ->registerClient ('http_client ' , $ this ->httpClientThatHasTracedRequests ([
426
414
[
427
415
'method ' => 'POST ' ,
428
416
'url ' => 'http://localhost:8057/json ' ,
429
417
'options ' => [
430
- 'body ' => str_repeat ( ' 1 ' , 257000 ) ,
418
+ 'body ' => [ ' file ' => fopen ( ' data://text/plain, ' , ' r ' )] ,
431
419
],
432
420
],
433
421
]));
0 commit comments