@@ -72,4 +72,40 @@ function it_formats_the_request_with_user_agent(RequestInterface $request, UriIn
7272
7373 $ this ->formatRequest ($ request )->shouldReturn ("curl 'http://foo.com/bar' -A 'foobar-browser' " );
7474 }
75+
76+ function it_formats_requests_with_null_bytes (RequestInterface $ request , UriInterface $ uri , StreamInterface $ body )
77+ {
78+ $ request ->getUri ()->willReturn ($ uri );
79+ $ request ->getBody ()->willReturn ($ body );
80+
81+ $ body ->__toString ()->willReturn ("\0" );
82+ $ body ->getSize ()->willReturn (1 );
83+ $ body ->isSeekable ()->willReturn (true );
84+ $ body ->rewind ()->willReturn (true );
85+
86+ $ uri ->withFragment ('' )->willReturn ('http://foo.com/bar ' );
87+ $ request ->getMethod ()->willReturn ('POST ' );
88+ $ request ->getProtocolVersion ()->willReturn ('1.1 ' );
89+ $ request ->getHeaders ()->willReturn ([]);
90+
91+ $ this ->formatRequest ($ request )->shouldReturn ("curl 'http://foo.com/bar' --request POST --data '[binary stream omitted]' " );
92+ }
93+
94+ function it_formats_requests_with_nonseekable_body (RequestInterface $ request , UriInterface $ uri , StreamInterface $ body )
95+ {
96+ $ request ->getUri ()->willReturn ($ uri );
97+ $ request ->getBody ()->willReturn ($ body );
98+
99+ $ body ->getSize ()->willReturn (1 );
100+ $ body ->isSeekable ()->willReturn (false );
101+ $ body ->__toString ()->shouldNotBeCalled ();
102+ $ body ->rewind ()->shouldNotBeCalled ();
103+
104+ $ uri ->withFragment ('' )->willReturn ('http://foo.com/bar ' );
105+ $ request ->getMethod ()->willReturn ('POST ' );
106+ $ request ->getProtocolVersion ()->willReturn ('1.1 ' );
107+ $ request ->getHeaders ()->willReturn ([]);
108+
109+ $ this ->formatRequest ($ request )->shouldReturn ("curl 'http://foo.com/bar' --request POST --data '[non-seekable stream omitted]' " );
110+ }
75111}
0 commit comments