phpxmlrpc
phpxmlrpc copied to clipboard
Unable to follow http to https redirect
Hi,
There seems to be a problem where PHPXMLRPC doesn't understand how to accept/decipher an http -> https redirect.
object(PhpXmlRpc\Response)[13] public 'val' => int 0 public 'valType' => null public 'errno' => int 5 public 'errstr' => string 'Didn't receive 200 OK from remote server. (HTTP/1.1 301 Moved Permanently)' (length=74) public 'payload' => null public 'hdrs' => array (size=0) empty
I fixed this in my posting script by adding these two lines:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_POSTREDIR, 7);
So I tried adding these lines in Client.php (near all of the cURL stuff) but it still doesn't work.
Any idea how to make PHPXMLRPC understand that http -> https redirects and valid and should be followed?
Hello.
Two things:
a) the Client class has a setCurlOptions
method already available. You can use that if you want to inject any custom curl option into your current code, without having to resort to 'hacking' the client
b) the Client does not always use curl out of the box- which might explain why your changes are not taken into account. If you want to make sure that curl is used, add a $client->setUseCurl(Client::USE_CURL_ALWAYS)
call
PS: adding "easy" support for allowing the client to follow redirects is in fact a worthwhile enhancement, and it has been in my todo list for a long time (see list at http://gggeek.github.io/phpxmlrpc/ )... I might create a separate ticket for that
Hello again. Did you manage to overcome your problem?
Long time no see :-)
I have tested following redirections, and indeed it was not possible to do so. The code has now been fixed to allow that - the end user will still have to manually set the relevant CURL options though.
This will be in upcoming release 4.9