function __construct($name = '', $parameters = array(), $namespace = null) { parent::__construct($name, $parameters); $this->ns = $namespace; }
/** * Build and return full HTTP payload out of a request obj (and other server status vars) * @param ggWebservicesRequest $request * @param bool $forCurl * @return string|array * @todo the API and code of this function is quite ugly ($forCurl usage) */ protected function payload($request, $forCurl = false) { $RequestHeaders = array(); // backward compatibility: if request does not specify a verb, let the client // pick one on its own $verb = $request->method(); if ($verb == '') { $verb = $this->Verb; } if (!$forCurl) { // if no proxy in use, URLS in request are not absolute but relative $uri = $request->requestURI($this->Path); // omit port if standard one is used if ($this->Protocol == 'http' && $this->Port == 80 || $this->Protocol == 'https' && $this->Port == 8443) { $port = ''; } else { $port = ':' . $this->Port; } if ($this->Proxy != '') { // if proxy in use, URLS in request are absolute $uri = $this->Protocol . '://' . $this->Server . $port . $uri; if ($this->ProxyLogin != '') { if ($this->ProxyAuthType != 1) { //error_log('Only Basic auth to proxy is supported yet'); } $RequestHeaders = array('Proxy-Authorization' => 'Basic ' . base64_encode($this->ProxyLogin . ':' . $this->ProxyPassword)); } } $HTTPRequest = $verb . " " . $uri . " HTTP/1.0\r\n" . "Host: " . $this->Server . $port . "\r\nConnection: close\r\n"; } // added extra request headers for eg SOAP clients /// @bug what if both client and request want to add eg COOKIES? $RequestHeaders = array_merge($this->RequestHeaders, $request->RequestHeaders(), $RequestHeaders); if (!$forCurl) { if ($this->login() != "") { if ($this->AuthType != 1) { //error_log('Only Basic auth is supported'); } $RequestHeaders['Authorization'] = "Basic " . base64_encode($this->login() . ":" . $this->password()); } if ($this->UserAgent != '') { $RequestHeaders['User-Agent'] = $this->UserAgent; } } if ($this->AcceptedCompression != '') { $RequestHeaders['Accept-Encoding'] = $this->AcceptedCompression; } if (count($this->Cookies)) { foreach ($this->Cookies as $cname => $cval) { $cookies[] = "{$cname}={$cval}"; } $RequestHeaders['Cookie'] = implode('; ', $cookies); } $payload = $request->payload(); if ($payload !== '') { if (($this->RequestCompression == 'gzip' || $this->RequestCompression == 'deflate') && function_exists('gzdeflate')) { if ($this->RequestCompression == 'gzip') { $a = @gzencode($payload); if ($a) { $payload = $a; $RequestHeaders['Content-Encoding'] = 'gzip'; } } else { $a = @gzcompress($payload); if ($a) { $payload = $a; $RequestHeaders['Content-Encoding'] = 'deflate'; } } } $ContentType = $request->contentType(); if ($ContentType == '') { $ContentType = $this->ContentType; } $RequestHeaders['Content-Type'] = $ContentType; if (!$forCurl) { $RequestHeaders['Content-Length'] = strlen($payload); } } /// @todo should we avoid sending header if value === ''? This way we allow users to unset them foreach ($RequestHeaders as $key => $val) { $RequestHeaders[$key] = "{$key}: {$val}"; } if (!$forCurl) { /// @bug in case there is no $RequestHeaders, we send one crlf too much? return $HTTPRequest . implode("\r\n", $RequestHeaders) . "\r\n\r\n" . $payload; } else { return array($verb, $RequestHeaders, $payload); } }
function __construct($name = '', $parameters = array()) { // strip out param names, since xmlrpc only uses positional params parent::__construct($name, array_values($parameters)); }
function __construct($name = '', $parameters = array(), $id = 1) { // strip out param names, since jsonrpc only uses positional params parent::__construct($name, array_values($parameters)); $this->Id = $id; }