File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -634,8 +634,20 @@ protected function metaToHeaders($meta) {
634
634
*/
635
635
protected function getStatusCode ($ meta ) {
636
636
$ matches = array ();
637
+
638
+ // We need last http status
639
+ $ statusHeader = NULL ;
640
+ foreach (array_reverse ($ meta ['wrapper_data ' ]) as $ header )
641
+ {
642
+ if (strpos ($ header , 'HTTP ' ) === 0 )
643
+ {
644
+ $ statusHeader = $ header ;
645
+ break ;
646
+ }
647
+ }
648
+
637
649
$ status = 0 ;
638
- preg_match ("|\s(\d\d\d)\s?| " , $ meta [ ' wrapper_data ' ][ 0 ] , $ matches );
650
+ preg_match ("|\s(\d\d\d)\s?| " , $ statusHeader , $ matches );
639
651
if (is_array ($ matches ) && isset ($ matches [1 ])) {
640
652
$ status = (int )trim ($ matches [1 ]);
641
653
}
@@ -854,6 +866,13 @@ protected function processResponseBody($resp) {
854
866
if ($ this ->parse_body === true ) {
855
867
856
868
$ header_content_type = isset ($ resp ['headers ' ]['Content-Type ' ]) ? $ resp ['headers ' ]['Content-Type ' ] : null ;
869
+
870
+ // If redirected, we use last Content-Type
871
+ if (is_array ($ header_content_type ))
872
+ {
873
+ $ header_content_type = end ($ header_content_type );
874
+ }
875
+
857
876
$ content_type = preg_split ('/[;\s]+/ ' , $ header_content_type );
858
877
$ content_type = $ content_type [0 ];
859
878
You can’t perform that action at this time.
0 commit comments