public function request(Request $request)
 {
     $statusCode = f\get_or($request->getParameters(), 'statusCode', 200);
     $content = $request->getParameters() ? json_encode($request->getParameters()) : $request->getContent();
     $headers = $request->getHeaders();
     return new Response($statusCode, $content, $headers);
 }
 public function convert(Request $request)
 {
     $headers = $request->getHeaders();
     $keysMap = f\map_indexed(function ($v, $k) {
         return 'HTTP_' . $k;
     }, $headers);
     $server = f\rename_keys($headers, $keysMap);
     return SymfonyRequest::create($request->getUri(), $request->getMethod(), $request->getParameters(), $cookies = array(), $files = array(), $server, $request->getContent());
 }
Esempio n. 3
0
 public function testSetters()
 {
     $request = new Request('GET', '/bar');
     $headers = range(1, 20);
     $request->setHeaders($headers);
     $this->assertSame($headers, $request->getHeaders());
     $parameters = range(1, 20);
     $request->setParameters($parameters);
     $this->assertSame($parameters, $request->getParameters());
     $content = 'foobar';
     $request->setContent($content);
     $this->assertSame($content, $request->getContent());
 }
 private function cleanRequest(Request $request, SymfonyRequest $symfonyRequest)
 {
     if (!array_key_exists('Accept', $request->getHeaders())) {
         $symfonyRequest->headers->remove('Accept');
     }
 }