forward_request

Forward an xmlrpc request to another server, and return to client the response received.

Description

forward_request( (xmlrpcmsg) $m ); 

Parameters (1)

0. $m (xmlrpcmsg)
(see method docs below for a description of the expected parameters)

Usage

  1. if ( !function_exists( 'forward_request' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7-infusionsoft-add-on/src/xmlrpc-3.0/demo/server/proxy.php'; 
  3.  
  4. // (see method docs below for a description of the expected parameters) 
  5. $m = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = forward_request($m); 
  9.  

Defined (1)

The function is defined in the following location(s).

/src/xmlrpc-3.0/demo/server/proxy.php  
  1. function forward_request($m) 
  2. // create client 
  3. $timeout = 0; 
  4. $url = php_xmlrpc_decode($m->getParam(0)); 
  5. $c = new xmlrpc_client($url); 
  6. if ($m->getNumParams() > 3) 
  7. // we have to set some options onto the client. 
  8. // Note that if we do not untaint the received values, warnings might be generated... 
  9. $options = php_xmlrpc_decode($m->getParam(3)); 
  10. foreach($options as $key => $val) 
  11. switch($key) 
  12. case 'Cookie': 
  13. break; 
  14. case 'Credentials': 
  15. break; 
  16. case 'RequestCompression': 
  17. $c->setRequestCompression($val); 
  18. break; 
  19. case 'SSLVerifyHost': 
  20. $c->setSSLVerifyHost($val); 
  21. break; 
  22. case 'SSLVerifyPeer': 
  23. $c->setSSLVerifyPeer($val); 
  24. break; 
  25. case 'Timeout': 
  26. $timeout = (integer) $val; 
  27. break; 
  28. } // switch 
  29.  
  30. // build call for remote server 
  31. /// @todo find a weay to forward client info (such as IP) to server, either 
  32. /// - as xml comments in the payload, or 
  33. /// - using std http header conventions, such as X-forwarded-for... 
  34. $method = php_xmlrpc_decode($m->getParam(1)); 
  35. $pars = $m->getParam(2); 
  36. $m = new xmlrpcmsg($method); 
  37. for ($i = 0; $i < $pars->arraySize(); $i++) 
  38. $m->addParam($pars->arraymem($i)); 
  39.  
  40. // add debug info into response we give back to caller 
  41. xmlrpc_debugmsg("Sending to server $url the payload: ".$m->serialize()); 
  42. return $c->send($m, $timeout);