Beispiel #1
0
 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $zendResponse->setStatusCode(200);
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = strtoupper($request->getMethod());
     $zendRequest->setCookies(new Parameters($request->getCookies()));
     if ($queryString) {
         parse_str($queryString, $query);
         $zendRequest->setQuery(new Parameters($query));
     }
     if ($request->getContent() !== null) {
         $zendRequest->setContent($request->getContent());
     } elseif ($method != HttpRequest::METHOD_GET) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($this->extractHeaders($request));
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
Beispiel #2
0
 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = $request->getMethod();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method == HttpRequest::METHOD_POST) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     } elseif ($method == HttpRequest::METHOD_GET) {
         $query = $request->getParameters();
         $zendRequest->setQuery(new Parameters($query));
     } elseif ($method == HttpRequest::METHOD_PUT) {
         $zendRequest->setContent($request->getContent());
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
Beispiel #3
0
 /**
  * @return String
  */
 protected function getActiveTab()
 {
     if (strpos($this->application->getRequest()->getRequestUri(), '/Summon/') !== false) {
         return 'Summon';
     } else {
         return 'Solr';
     }
 }
Beispiel #4
0
 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $this->createApplication();
     $zendRequest = $this->application->getRequest();
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = strtoupper($request->getMethod());
     $zendRequest->setCookies(new Parameters($request->getCookies()));
     $query = [];
     $post = [];
     $content = $request->getContent();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method !== HttpRequest::METHOD_GET) {
         $post = $request->getParameters();
     }
     $zendRequest->setQuery(new Parameters($query));
     $zendRequest->setPost(new Parameters($post));
     $zendRequest->setFiles(new Parameters($request->getFiles()));
     $zendRequest->setContent($content);
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $requestUri = $uri->getPath();
     if (!empty($queryString)) {
         $requestUri .= '?' . $queryString;
     }
     $zendRequest->setRequestUri($requestUri);
     $zendRequest->setHeaders($this->extractHeaders($request));
     $this->application->run();
     // get the response *after* the application has run, because other ZF
     //     libraries like API Agility may *replace* the application's response
     //
     $zendResponse = $this->application->getResponse();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
Beispiel #5
0
 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $zendHeaders = $zendRequest->getHeaders();
     if (!$zendHeaders->has('Content-Type')) {
         $server = $request->getServer();
         if (isset($server['CONTENT_TYPE'])) {
             $zendHeaders->addHeaderLine('Content-Type', $server['CONTENT_TYPE']);
         }
     }
     $zendResponse->setStatusCode(200);
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = strtoupper($request->getMethod());
     $zendRequest->setCookies(new Parameters($request->getCookies()));
     if ($queryString) {
         parse_str($queryString, $query);
         $zendRequest->setQuery(new Parameters($query));
     }
     if ($method == HttpRequest::METHOD_POST) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     } elseif ($method == HttpRequest::METHOD_PUT) {
         $zendRequest->setContent($request->getContent());
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }