Make WordPress Core

Ticket #34796: 34796.diff

File 34796.diff, 676 bytes (added by rmccue, 9 years ago)

Wait for socket to be ready before writing to it

  • src/wp-includes/class-wp-http-streams.php

     
    203203                if ( ! is_null($r['body']) )
    204204                        $strHeaders .= $r['body'];
    205205
     206                // Ensure the stream is ready to write to
     207                $no_streams = array();
     208                $write_streams = array( $handle );
     209                if ( ! stream_select( $no_streams, $write_streams, $no_streams, 0, 50 ) ) {
     210                        return new WP_Error( 'http_request_failed', __( 'Could not open outbound stream' ) );
     211                }
     212
    206213                fwrite($handle, $strHeaders);
    207214
    208215                if ( ! $r['blocking'] ) {