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

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

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

User Contributed Notes

You must log in before being able to contribute a note or feedback.