@@ -209,7 +209,7 @@ public function testDefaultBodyLengthTooLong(): void
209209 $ this ->expectException (StreamException::class);
210210
211211 try {
212- $ this ->fetch (self ::buildDataSource ('big.php ' ));
212+ $ this ->fetch (self ::buildDataSource ('big.php ' ))-> getBody () ;
213213 } finally {
214214 $ this ->stopServer ($ server );
215215 }
@@ -227,7 +227,7 @@ public function testCustomBodyLengthTooLong(): void
227227 $ this ->expectException (StreamException::class);
228228
229229 try {
230- $ this ->fetch (self ::buildDataSource ());
230+ $ this ->fetch (self ::buildDataSource ())-> getBody () ;
231231 } finally {
232232 $ this ->stopServer ($ server );
233233 }
@@ -243,12 +243,25 @@ public function testCustomBodyLengthOverride(): void
243243 $ this ->expectException (StreamException::class);
244244
245245 try {
246- $ this ->fetch (self ::buildDataSource ()->setMaxBodyLength (1 ));
246+ $ this ->fetch (self ::buildDataSource ()->setMaxBodyLength (1 ))-> getBody () ;
247247 } finally {
248248 $ this ->stopServer ($ server );
249249 }
250250 }
251251
252+ public function testUserAgentOverride (): void
253+ {
254+ $ server = $ this ->startServer ();
255+
256+ try {
257+ $ response = $ this ->fetch (self ::buildDataSource ()->addHeader ($ h = 'user-agent ' , $ v = 'Alfa ' ))->getBody ();
258+ } finally {
259+ $ this ->stopServer ($ server );
260+ }
261+
262+ self ::assertMatchesRegularExpression ("[^ $ h: $ v$]m " , $ response );
263+ }
264+
252265 private function startServer (): Process
253266 {
254267 $ server = new Process ([PHP_BINARY , '-S ' , self ::HOST , '-t ' , self ::DIR ]);
0 commit comments