Exemplo n.º 1
0
 public function request($resource, $method = "GET", $data = array(), $immediate = true, $compression = "gzip")
 {
     if (!is_array($data)) {
         $data = array();
     }
     $data = array_merge($this->_reqData, $data);
     return parent::request($resource, $method, $data, $immediate, $compression);
 }
Exemplo n.º 2
0
            curl_setopt($ch, CURLOPT_HTTPGET, true);
        }
        $output = curl_exec($ch);
        // Get the request info for headers
        $info = curl_getinfo($ch);
        // Set our headers to the headers we received from the REST API
        header('Content-Type: ' . $info['content_type']);
        !$info['http_code'] ? $info['http_code'] = "502" : ($info['http_code'] = $info['http_code']);
        header('HTTP/1.1 ' . $info['http_code'] . ' ' . $this->HTTPErrorCodes[$info['http_code']]);
        // Some informatic headers
        header('x-RESTProxy-url: ' . $info['url']);
        header('x-RESTProxy-total-time: ' . $info['total_time']);
        header('x-RESTProxy-namelookup-time: ' . $info['namelookup_time']);
        header('x-RESTProxy-connect-time: ' . $info['connect_time']);
        header('x-RESTProxy-size-upload: ' . $info['size_upload']);
        header('x-RESTProxy-size-download: ' . $info['size_download']);
        header('x-RESTProxy-speed-download: ' . $info['speed_download']);
        header('x-RESTProxy-speed-upload: ' . $info['speed_upload']);
        header('x-RESTProxy-download-content-lenght: ' . $info['download_content_length']);
        header('x-RESTProxy-upload-content-lenght: ' . $info['upload_content_length']);
        header('x-RESTProxy-start-transfer-time: ' . $info['starttransfer_time']);
        header('x-RESTProxy-redirect-time: ' . $info['redirect_time']);
        //var_dump($info);
        // Return the output
        echo $output;
        fclose($this->fp);
        curl_close($ch);
    }
}
$proxy = new RESTProxy();
$proxy->doRequest();