I'm using the Git PHP-SharePoint-Lists-API library with NTLM auth. It sends a POST request via lib cURL (I'm running Windows PHP 5.5.11 with lib cURL 7.35.0).
Problem is that the NTLM auth response generated by cURL doesn't include a Content-Length
header and SharePoint 2013 doesn't seem to like that. It returns an HTTP 411 error, content length missing
I've found discussions of this issue in multiple places but no actual solutions. Thanks for any ideas.
Calling via cURL from SoapClientAuth.php
$ch = curl_init($location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_FAILONERROR, FALSE);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $this->Username . ':' . $this->Password);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_CERTINFO, TRUE);
if ($DEBUGGING) {
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
}
$response = curl_exec($ch);
First Request
POST http://sp2013server.com/marketing/_vti_bin/Lists.asmx HTTP/1.1
Host: sp2013server.arx.com
Accept: */*
Connection: Keep-Alive
User-Agent: PHP-SOAP
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListCollection"
Content-Length: 251
Expect: 100-continue
Connection: Keep-Alive
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas... blah
First Response
HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Length: 16
Content-Type: text/plain; charset=windows-1255
SPRequestGuid: 5b93869c-5b72-8091-555a-8d0d25f77b1e
request-id: 5b93869c-5b72-8091-555a-8d0d25f77b1e
X-FRAME-OPTIONS: SAMEORIGIN
SPRequestDuration: 8
SPIisLatency: 6
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
WWW-Authenticate: NTLM
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
MicrosoftSharePointTeamServices: 15.0.0.4420
Date: Sat, 12 Apr 2014 17:42:49 GMT
Proxy-Support: Session-Based-Authentication
401 UNAUTHORIZED
Second Request (generated by CURL, not by a client call)
POST http://sp2013server.arx.com/marketing/_vti_bin/Lists.asmx HTTP/1.1
Authorization: NTLM TlRMxxxxxxxxxxx==
Host: sp2013server.arx.com
Accept: */*
Connection: Keep-Alive
User-Agent: PHP-SOAP
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListCollection"
Expect: 100-continue
Connection: Keep-Alive
Second Response
HTTP/1.1 411 Length Required
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Sat, 12 Apr 2014 17:42:50 GMT
Connection: close
Content-Length: 344
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>