Requests_Transport_cURL::get_expect_header()

最后更新于:2021-11-26 04:06:10

Requests_Transport_cURL::get_expect_header( string|array$data)

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

参数

$data

(string|array) (Required) Data to send either as the POST body, or as parameters in the URL for a GET/HEAD.

响应

(string) The “Expect” header.

源文件

文件: gc-includes/Requests/Transport/cURL.php

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