diff --git a/src/main/php/webservices/rest/RestClient.class.php b/src/main/php/webservices/rest/RestClient.class.php index c5f75366..8789b47e 100644 --- a/src/main/php/webservices/rest/RestClient.class.php +++ b/src/main/php/webservices/rest/RestClient.class.php @@ -1,11 +1,12 @@ connection) { throw new IllegalStateException('No connection set'); } + $targetUrl= $request->targetUrl(new URL()); + $send= $this->connection->create(new HttpRequest()); $send->addHeaders($request->headerList()); $send->setMethod($request->getMethod()); - $send->setTarget($request->getTarget($this->connection->getUrl()->getPath('/'))); + $send->setTarget($targetUrl->getPath('/')); // Compose body // * Serialize payloads using the serializer for the given mimetype @@ -212,18 +216,20 @@ public function execute(RestRequest $request) { )); } else if ($request->hasBody()) { $send->setParameters($request->getBody()); - } else { - $send->setParameters($request->getParameters()); + } else if ($targetUrl->hasParams()) { + $send->setParameters($targetUrl->getParams()); } try { $this->cat && $this->cat->debug('>>>', $send->getRequestString()); $response= $this->connection->send($send); - } catch (\io\IOException $e) { + } catch (IOException $e) { throw new RestException('Cannot send request', $e); } - $reader= new ResponseReader($this->deserializerFor($response->header('Content-Type')[0]), $this->marshalling); + $reader= new ResponseReader( + $this->deserializerFor($response->header('Content-Type')[0]), $this->marshalling + ); $result= new RestResponse($response, $reader); $this->cat && $this->cat->debug('<<<', $response->toString(), $result->contentCopy());