W3cubDocs

/WordPress

Curl::get_expect_header( string|array $data ): string

Get the correct “Expect” header for the given request data.

Parameters

$datastring|arrayrequired
Data to send either as the POST body, or as parameters in the URL for a GET/HEAD.

Return

string The "Expect" header.

Source

		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 '';
	}
}

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wporg-requests-transport-curl/get_expect_header