@@ -144,7 +144,10 @@ private function request($params, $url = Tiny_Config::URL) {
144144 }
145145
146146 $ meta_data = stream_get_meta_data ( $ request );
147- $ headers = iterator_to_array ( $ meta_data ['wrapper_data ' ] );
147+ $ headers = $ meta_data ['wrapper_data ' ];
148+ if ( ! is_array ( $ headers ) ) {
149+ $ headers = iterator_to_array ( $ headers );
150+ }
148151
149152 $ status_code = $ this ->parse_status_code ( $ headers );
150153 $ headers = $ this ->parse_headers ( $ headers );
@@ -162,9 +165,9 @@ private function request($params, $url = Tiny_Config::URL) {
162165 return array ( $ response , $ headers , $ status_code );
163166 }
164167
165- private function parse_status_code ($ header ) {
166- if ( $ header && count ( $ header ) > 0 ) {
167- $ http_code_values = explode ( ' ' , $ header [0 ] );
168+ private function parse_status_code ($ headers ) {
169+ if ( $ headers && count ( $ headers ) > 0 ) {
170+ $ http_code_values = explode ( ' ' , $ headers [0 ] );
168171 if ( count ( $ http_code_values ) > 1 ) {
169172 return intval ( $ http_code_values [1 ] );
170173 }
@@ -173,9 +176,6 @@ private function parse_status_code($header) {
173176 }
174177
175178 private function parse_headers ($ headers ) {
176- if ( ! is_array ( $ headers ) ) {
177- $ headers = explode ( "\r\n" , $ headers );
178- }
179179 $ res = array ();
180180 foreach ( $ headers as $ header ) {
181181 $ split = explode ( ': ' , $ header , 2 );
0 commit comments