According to RFC2616 10.4.12 :
10.4.12 411 Length Required
The server refuses to accept the request without a defined Content-
Length. The client MAY repeat the request if it adds a valid
Content-Length header field containing the length of the message-body
in the request message.
Content-Length POST. () POST. , strlen POST. POST, . ['http']['content'] .
, , content (. HTTP & shy; Docs).
: . , XML- POST file_get_contents , Content-Length.
$url = 'https://api.example.com/action';
$requestXML = '<xml><!-- ... the xml you want to post to the server... --></xml>';
$requestHeaders = array(
'Content-type: application/x-www-form-urlencoded',
'Accept: application/xml',
sprintf('Content-Length: %d', strlen($requestXML));
);
$context = stream_context_create(
array(
'http' => array(
'method' => 'POST',
'header' => implode("\r\n", $requestHeaders),
'content' => $requestXML,
)
)
);
$responseXML = file_get_contents($url, false, $context);
if (FALSE === $responseXML)
{
throw new RuntimeException('HTTP request failed.');
}
, . ignore_errors HTTP & shy; Docs $http_response_header & shy; Docs. HTTP- : HEAD PHP.