2424use WpOrg \Requests \Transport \Curl ;
2525use WpOrg \Requests \Transport \Fsockopen ;
2626use WpOrg \Requests \Utility \InputValidator ;
27+ use WpOrg \Requests \Utility \Trim ;
2728
2829/**
2930 * Requests for PHP
3536 * @package Requests
3637 */
3738class Requests {
39+ /**
40+ * Current version of Requests
41+ *
42+ * @var string
43+ */
44+ const VERSION = '2.0.21 ' ;
45+
3846 /**
3947 * POST method
4048 *
@@ -143,13 +151,6 @@ class Requests {
143151 Fsockopen::class => Fsockopen::class,
144152 ];
145153
146- /**
147- * Current version of Requests
148- *
149- * @var string
150- */
151- const VERSION = '2.0.17 ' ;
152-
153154 /**
154155 * Selected transport name
155156 *
@@ -763,7 +764,7 @@ protected static function parse_response($headers, $url, $req_headers, $req_data
763764
764765 foreach ($ headers as $ header ) {
765766 list ($ key , $ value ) = explode (': ' , $ header , 2 );
766- $ value = trim ($ value );
767+ $ value = trim ($ value, Trim:: WHITESPACE_CHARS_NO_FF );
767768 preg_replace ('#(\s+)#i ' , ' ' , $ value );
768769 $ return ->headers [$ key ] = $ value ;
769770 }
@@ -790,7 +791,7 @@ protected static function parse_response($headers, $url, $req_headers, $req_data
790791 $ options ['type ' ] = self ::GET ;
791792 }
792793
793- $ options ['redirected ' ]++ ;
794+ ++ $ options ['redirected ' ];
794795 $ location = $ return ->headers ['location ' ];
795796 if (strpos ($ location , 'http:// ' ) !== 0 && strpos ($ location , 'https:// ' ) !== 0 ) {
796797 // relative redirect, for compatibility make it absolute
@@ -852,7 +853,7 @@ public static function parse_multiple(&$response, $request) {
852853 * @return string Decoded body
853854 */
854855 protected static function decode_chunked ($ data ) {
855- if (!preg_match ('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i ' , trim ($ data ))) {
856+ if (!preg_match ('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i ' , trim ($ data, Trim:: WHITESPACE_CHARS_NO_FF ))) {
856857 return $ data ;
857858 }
858859
@@ -866,7 +867,7 @@ protected static function decode_chunked($data) {
866867 return $ data ;
867868 }
868869
869- $ length = hexdec (trim ($ matches [1 ]));
870+ $ length = hexdec (trim ($ matches [1 ], Trim:: WHITESPACE_CHARS_NO_FF ));
870871 if ($ length === 0 ) {
871872 // Ignore trailer headers
872873 return $ decoded ;
@@ -876,7 +877,7 @@ protected static function decode_chunked($data) {
876877 $ decoded .= substr ($ encoded , $ chunk_length , $ length );
877878 $ encoded = substr ($ encoded , $ chunk_length + $ length + 2 );
878879
879- if (trim ($ encoded ) === '0 ' || empty ($ encoded )) {
880+ if (trim ($ encoded, Trim:: WHITESPACE_CHARS_NO_FF ) === '0 ' || empty ($ encoded )) {
880881 return $ decoded ;
881882 }
882883 }
@@ -923,7 +924,7 @@ public static function decompress($data) {
923924 throw InvalidArgument ::create (1 , '$data ' , 'string ' , gettype ($ data ));
924925 }
925926
926- if (trim ($ data ) === '' ) {
927+ if (trim ($ data, Trim:: WHITESPACE_CHARS_NO_FF ) === '' ) {
927928 // Empty body does not need further processing.
928929 return $ data ;
929930 }
@@ -990,7 +991,7 @@ public static function compatible_gzinflate($gz_data) {
990991 throw InvalidArgument ::create (1 , '$gz_data ' , 'string ' , gettype ($ gz_data ));
991992 }
992993
993- if (trim ($ gz_data ) === '' ) {
994+ if (trim ($ gz_data, Trim:: WHITESPACE_CHARS_NO_FF ) === '' ) {
994995 return false ;
995996 }
996997
0 commit comments