Make WordPress Core

Ticket #26726: 26726.diff

File 26726.diff, 1.5 KB (added by bradyvercher, 12 years ago)
  • wp-includes/class-http.php

     
    10871087        private $max_body_length = false;
    10881088
    10891089        /**
     1090         * The total bytes written in the current request.
     1091         *
     1092         * @since 3.9.0
     1093         * @access prviate
     1094         * @var int
     1095         */
     1096        private $bytes_written_total = 0;
     1097
     1098        /**
    10901099         * The file resource used for streaming to file.
    10911100         *
    10921101         * @since 3.6.0
     
    12521261
    12531262                $this->headers = '';
    12541263                $this->body = '';
     1264                $this->bytes_written_total = 0;
    12551265
    12561266                $curl_error = curl_errno( $handle );
    12571267
     
    13271337        private function stream_body( $handle, $data ) {
    13281338                $data_length = strlen( $data );
    13291339
    1330                 if ( $this->max_body_length && ( strlen( $this->body ) + $data_length ) > $this->max_body_length )
    1331                         $data = substr( $data, 0, ( $this->max_body_length - $data_length ) );
     1340                if ( $this->max_body_length && ( $this->bytes_written_total + $data_length ) > $this->max_body_length )
     1341                        $data = substr( $data, 0, ( $this->max_body_length - $this->bytes_written_total - $data_length ) );
    13321342
    13331343                if ( $this->stream_handle ) {
    13341344                        $bytes_written = fwrite( $this->stream_handle, $data );
     
    13371347                        $bytes_written = $data_length;
    13381348                }
    13391349
     1350                $this->bytes_written_total .= $bytes_written;
     1351
    13401352                // Upon event of this function returning less than strlen( $data ) curl will error with CURLE_WRITE_ERROR
    13411353                return $bytes_written;
    13421354        }