summaryrefslogtreecommitdiffstats
path: root/lib/kolab_api_controller.php
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2012-02-17 16:43:54 +0100
committerAleksander Machniak <machniak@kolabsys.com>2012-02-17 16:43:54 +0100
commit6b0c6b418effe6bb6780ff71e5c5f4ea3c1df2cf (patch)
tree96b6e6b3642003d59e2d2fa0464e5d1cf0f639c6 /lib/kolab_api_controller.php
parentbb573fa56d4fa2995071444b714916e49fb25f7d (diff)
downloadwebadmin-6b0c6b418effe6bb6780ff71e5c5f4ea3c1df2cf.tar.gz
Fixed proxy feature, some fixes here and there
Diffstat (limited to 'lib/kolab_api_controller.php')
-rw-r--r--lib/kolab_api_controller.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php
index d5652aa..dbfa02a 100644
--- a/lib/kolab_api_controller.php
+++ b/lib/kolab_api_controller.php
@@ -108,7 +108,7 @@ class kolab_api_controller
$service = $this->request['service'];
$method = $this->request['method'];
- $postdata = @json_decode($postdata);
+ $postdata = @json_decode($postdata, true);
console("Calling method " . $method . " on service " . $service);
// validate user session
@@ -152,22 +152,32 @@ class kolab_api_controller
{
$service = $this->request['service'];
$method = $this->request['method'];
- $url .= '/' . $service . '.' . $method;
+ $url = rtrim($url, '/') . '/' . $service . '.' . $method;
console("Proxying " . $url);
$request = new HTTP_Request2();
$url = new Net_URL2($url);
$method = strtoupper($_SERVER['REQUEST_METHOD']);
+ $get = array('proxy' => 1); // Prevent from infinite redirect
$request->setMethod($method == 'GET' ? HTTP_Request2::METHOD_GET : HTTP_Request2::METHOD_POST);
$request->setHeader('X-Session-Token', kolab_utils::get_request_header('X-Session-Token'));
if ($method == 'GET') {
+ parse_str($_SERVER['QUERY_STRING'], $query);
+ unset($query['service']);
+ unset($query['method']);
+
+ $query = array_map('urldecode', $query);
+ $get = array_merge($query, $get);
+ }
+ else {
$request->setBody($postdata);
}
try {
+ $url->setQueryVariables($get);
$request->setUrl($url);
$response = $request->send();
}