WpOrg\Requests\Transport

Curl::get_expect_header()privateWP 1.0

Get the correct "Expect" header for the given request data.

Method of the class: Curl{}

No Hooks.

Return

String. The "Expect" header.

Usage

// private - for code of main (parent) class only
$result = $this->get_expect_header( $data );
$data(string|array) (required)
Data to send either as the POST body, or as parameters in the URL for a GET/HEAD.

Curl::get_expect_header() code WP 6.6.2

private function get_expect_header($data) {
	if (!is_array($data)) {
		return strlen((string) $data) >= 1048576 ? '100-Continue' : '';
	}

	$bytesize = 0;
	$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data));

	foreach ($iterator as $datum) {
		$bytesize += strlen((string) $datum);

		if ($bytesize >= 1048576) {
			return '100-Continue';
		}
	}

	return '';
}