1616use  InvalidArgumentException ;
1717
1818/** 
19-  * Class OutgoingRequest 
20-  * 
21-  * A lightweight HTTP client for sending synchronous HTTP requests 
22-  * via cURL. 
19+  * A lightweight HTTP client for sending synchronous HTTP requests via cURL. 
2320 */ 
2421class  CURLRequest extends  Request
2522{
@@ -84,10 +81,7 @@ class CURLRequest extends Request
8481    public  function  __construct (App   $ config , URI   $ uri , ?ResponseInterface   $ response  = null , array  $ options  = [])
8582    {
8683        if  (! function_exists ('curl_version ' )) {
87-             // we won't see this during travis-CI 
88-             // @codeCoverageIgnoreStart 
89-             throw  HTTPException::forMissingCurl ();
90-             // @codeCoverageIgnoreEnd 
84+             throw  HTTPException::forMissingCurl (); // @codeCoverageIgnore 
9185        }
9286
9387        parent ::__construct ($ config );
@@ -110,9 +104,7 @@ public function request($method, string $url, array $options = []): ResponseInte
110104
111105        $ url  = $ this  ->prepareURL ($ url );
112106
113-         $ method  = filter_var ($ method , FILTER_SANITIZE_STRING );
114- 
115-         $ this  ->send ($ method , $ url );
107+         $ this  ->send (esc (strip_tags ($ method )), $ url );
116108
117109        return  $ this  ->response ;
118110    }
@@ -182,11 +174,7 @@ public function put(string $url, array $options = []): ResponseInterface
182174     */ 
183175    public  function  setAuth (string  $ username , string  $ password , string  $ type  = 'basic ' )
184176    {
185-         $ this  ->config ['auth ' ] = [
186-             $ username ,
187-             $ password ,
188-             $ type ,
189-         ];
177+         $ this  ->config ['auth ' ] = [$ username , $ password , $ type ];
190178
191179        return  $ this  ;
192180    }
@@ -260,14 +248,12 @@ protected function parseOptions(array $options)
260248     */ 
261249    protected  function  prepareURL (string  $ url ): string 
262250    {
263-         // If it's a full URI, then we have nothing to do here... 
264251        if  (strpos ($ url , ':// ' ) !== false ) {
265252            return  $ url ;
266253        }
267254
268255        $ uri  = $ this  ->baseURI ->resolveRelativeURI ($ url );
269256
270-         // Create the string instead of casting to prevent baseURL muddling 
271257        return  URI ::createURIString ($ uri ->getScheme (), $ uri ->getAuthority (), $ uri ->getPath (), $ uri ->getQuery (), $ uri ->getFragment ());
272258    }
273259
@@ -279,7 +265,7 @@ protected function prepareURL(string $url): string
279265     */ 
280266    public  function  getMethod (bool  $ upper  = false ): string 
281267    {
282-         return  ( $ upper)  ? strtoupper ($ this  ->method ) : strtolower ($ this  ->method );
268+         return  $ upper  ? strtoupper ($ this  ->method ) : strtolower ($ this  ->method );
283269    }
284270
285271    /** 
@@ -386,10 +372,9 @@ protected function applyMethod(string $method, array $curlOptions): array
386372    {
387373        $ method  = strtoupper ($ method );
388374
389-         $ this  ->method                        = $ method ;
390-         $ curlOptions [CURLOPT_CUSTOMREQUEST ] = $ method ;
375+         $ this  ->method  = $ curlOptions [CURLOPT_CUSTOMREQUEST ] = $ method ;
391376
392-         $ size  = strlen ($ this  ->body );
377+         $ size  = strlen ($ this  ->body  ??  '' );
393378
394379        // Have content? 
395380         if  ($ size  > 0 ) {
0 commit comments