Make WordPress Core

Ticket #13841: 13841.3.diff

File 13841.3.diff, 1.6 KB (added by aaroncampbell, 14 years ago)

Re-refreshed patch

  • wp-includes/class-http.php

     
    100100                        'sslverify' => true
    101101                );
    102102
    103                
     103
    104104                // Pre-parse for the HEAD checks.
    105105                $args = wp_parse_args( $args );
    106106
     
    659659                }
    660660
    661661                $strResponse = '';
    662                 while ( ! feof($handle) )
    663                         $strResponse .= fread($handle, 4096);
     662                while ( ! feof($handle) ) {
     663                        $info = stream_get_meta_data( $handle );
     664                        if ( $info['timed_out'] )
     665                                return new WP_Error('http_request_failed', __('Request timed out.'));
     666                        $strResponse .= fread( $handle, 4096 );
     667                }
    664668
    665669                fclose($handle);
    666670
     
    814818                if ( ! empty($r['body'] ) )
    815819                        $arrContext['http']['content'] = $r['body'];
    816820
     821                // timeouts with stream_contect_create for some reason need to be half of what you expect
     822                $arrContext['http']['timeout'] = $r['timeout'] / 2;
     823
    817824                $context = stream_context_create($arrContext);
    818825
    819826                if ( !WP_DEBUG )
     
    845852                else
    846853                        $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
    847854
    848                 // Streams does not provide an error code which we can use to see why the request stream stoped. 
     855                // Streams does not provide an error code which we can use to see why the request stream stoped.
    849856                // We can however test to see if a location header is present and return based on that.
    850857                if ( isset($processedHeaders['headers']['location']) && 0 !== $args['_redirection'] )
    851858                        return new WP_Error('http_request_failed', __('Too many redirects.'));