Requests_Transport_cURL::stream_body

Advertisement

Summery Summery

Collect data as it’s received

Syntax Syntax

Requests_Transport_cURL::stream_body( resource $handle, string $data )

Parameters Parameters

$handle

(resource) (Required) cURL resource

$data

(string) (Required) Body data

Return Return

(integer) Length of provided data

Source Source

File: wp-includes/Requests/Transport/cURL.php

	public function stream_body($handle, $data) {
		$this->hooks->dispatch('request.progress', array($data, $this->response_bytes, $this->response_byte_limit));
		$data_length = strlen($data);

		// Are we limiting the response size?
		if ($this->response_byte_limit) {
			if ($this->response_bytes === $this->response_byte_limit) {
				// Already at maximum, move on
				return $data_length;
			}

			if (($this->response_bytes + $data_length) > $this->response_byte_limit) {
				// Limit the length
				$limited_length = ($this->response_byte_limit - $this->response_bytes);
				$data = substr($data, 0, $limited_length);
			}
		}

		if ($this->stream_handle) {
			fwrite($this->stream_handle, $data);
		}
		else {
			$this->response_data .= $data;
		}

		$this->response_bytes += strlen($data);
		return $data_length;
	}

Advertisement

Changelog Changelog

Changelog
Version Description
1.6.1 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.