+ /**
+ * Grab the body of the cURL request
+ *
+ * The contents of the document are passed in chunks, so we append to the $body property for temporary storage.
+ * Returning a length shorter than the length of $data passed in will cause cURL to abort the request as "completed"
+ *
+ * @since 3.6.0
+ * @access private
+ * @return int
+ */
+ private function stream_body( $handle, $data ) {
+ if ( function_exists( 'ini_get' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ) && function_exists( 'mb_internal_encoding' ) ) {
+ $mb_encoding = mb_internal_encoding();
+ mb_internal_encoding( 'ISO-8859-1' );
+ }
+
+ if ( $this->max_body_length && ( strlen( $this->body ) + strlen( $data ) ) > $this->max_body_length )
+ $data = substr( $data, 0, ( $this->max_body_length - strlen( $this->body ) ) );
+
+ if ( $this->stream_handle )
+ fwrite( $this->stream_handle, $data );
+ else
+ $this->body .= $data;
+
+ $data_length = strlen( $data );
+
+ if ( isset( $mb_encoding ) )
+ mb_internal_encoding( $mb_encoding );
+
+ return $data_length;
+ }
+