curl error 411 bij migratie van PHP 5.3 naar 5.6

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • Douweegbertje
  • Registratie: Mei 2008
  • Laatst online: 08-09 15:03

Douweegbertje

Wat kinderachtig.. godverdomme

Topicstarter
Ik ben bezig met het migreren van de codebase van PHP 5.3 naar PHP 5.6.3. Ik heb een stukje waar ik een curl request doe maar dit geeft nu opeens een curl error 411
The requested URL returned error: 411 Length Required
Ik heb alle data vergeleken maar dit exact het zelfde. Mijn 'msg' is een string van 620 karakters, de lengte die ik mee geef in de httpheader is correct en identiek aan het geen zoals het in PHP 5.3 was.

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$handle   = curl_init();

curl_setopt($handle,     CURLOPT_URL, $this->_url);
curl_setopt($handle,     CURLOPT_FAILONERROR, true);
curl_setopt($handle,     CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: ".$request."","Content-length: ".strlen($msg))); 
curl_setopt($handle,     CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle,     CURLOPT_POSTFIELDS, $msg);
curl_setopt($handle,     CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle,     CURLOPT_SSL_VERIFYPEER, 0); 

curl_setopt($handle,     CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($handle,     CURLOPT_USERPWD, $this->_httpUser.':'.$this->_httpPassword);

$response = curl_exec($handle);
cURL Information 7.39.0
Ik heb alle changes van PHP doorgelopen, maar het enige wat ik kan vinden met curl is de file syntax, echter is dat niet van toepassing voor mij.
http://php.net/manual/en/migration56.changed-functions.php

Acties:
  • 0 Henk 'm!

  • sky-
  • Registratie: November 2005
  • Niet online

sky-

qn ella 👌

Ik zou op deze regel:

code:
1
curl_setopt($handle,     CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: ".$request."","Content-length: ".strlen($msg)));


Het gedeelte van Content-length weghalen. Dit doet libcurl al voor je. Ik gok dat daar zo'n beetje de fout zit.

don't be afraid of machines, be afraid of the people who build and train them.


Acties:
  • 0 Henk 'm!

  • Douweegbertje
  • Registratie: Mei 2008
  • Laatst online: 08-09 15:03

Douweegbertje

Wat kinderachtig.. godverdomme

Topicstarter
8)7

Ok, dat werkt inderdaad.
Het is mij een raadsel waarom het in 5.3 wel werkt en in 5.6 niet :+

Acties:
  • 0 Henk 'm!

  • sky-
  • Registratie: November 2005
  • Niet online

sky-

qn ella 👌

Komt door de (vage) combinatie met CURLOPT_POSTFIELDS. Niets om je druk om te maken :+.

don't be afraid of machines, be afraid of the people who build and train them.