Make WordPress Core

Ticket #13841: 13841.4.diff

File 13841.4.diff, 1.8 KB (added by sivel, 14 years ago)

Refreshed patch

  • wp-includes/class-http.php

     
    697697                                return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) );
    698698
    699699                        while ( ! feof($handle) ) {
     700                                $info = stream_get_meta_data( $handle );
     701                                if ( $info['timed_out'] )
     702                                        return new WP_Error('http_request_failed', __('Request timed out.'));
    700703                                $block = fread( $handle, 4096 );
    701704                                if ( $bodyStarted ) {
    702705                                        fwrite( $stream_handle, $block );
     
    716719
    717720                } else {
    718721                        while ( ! feof($handle) )
     722                                $info = stream_get_meta_data( $handle );
     723                                if ( $info['timed_out'] )
     724                                        return new WP_Error('http_request_failed', __('Request timed out.'));
    719725                                $strResponse .= fread( $handle, 4096 );
    720726
    721727                        $process = WP_Http::processResponse( $strResponse );
     
    868874                if ( ! empty($r['body'] ) )
    869875                        $arrContext['http']['content'] = $r['body'];
    870876
     877                // timeouts with stream_contect_create for some reason need to be half of what you expect
     878                $arrContext['http']['timeout'] = $r['timeout'] / 2;
     879
    871880                $context = stream_context_create($arrContext);
    872881
    873882                if ( !WP_DEBUG )
     
    915924                else
    916925                        $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
    917926
    918                 // Streams does not provide an error code which we can use to see why the request stream stoped.
     927                // Streams does not provide an error code which we can use to see why the request stream stopped.
    919928                // We can however test to see if a location header is present and return based on that.
    920929                if ( isset($processedHeaders['headers']['location']) && 0 !== $args['_redirection'] )
    921930                        return new WP_Error('http_request_failed', __('Too many redirects.'));