getRealMethod() public method

Gets the "real" request method.
See also: getMethod()
public getRealMethod ( ) : string
return string The request method
Ejemplo n.º 1
0
 public function getRequestParameters()
 {
     if ($this->request->getRealMethod() === 'POST') {
         return $this->request->request->all();
     } else {
         return $this->request->query->all();
     }
 }
 /**
  * Log an incoming request from the middleware.
  *
  * @param Request $request
  *                         The incoming request.
  * @param int     $type
  *                         The type of request (master or sub request).
  */
 protected function logRequest(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
 {
     if ($type == HttpKernelInterface::MASTER_REQUEST) {
         // Starts timers and logs.
         Database::startLog('console_logger');
         if ($request->getRealMethod() == 'POST') {
             $parameters = $request->request->all();
             $parameters = $this->sanitizeParameters($parameters);
             if (!empty($parameters)) {
                 $this->logger->log($this->logLevel, 'Request parameters', $parameters);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Handles the request token.
  *
  * @throws AjaxRedirectResponseException|InvalidRequestTokenException If the token is invalid
  */
 private function handleRequestToken()
 {
     // Deprecated since Contao 4.0, to be removed in Contao 5.0
     if (!defined('REQUEST_TOKEN')) {
         define('REQUEST_TOKEN', $this->tokenManager->getToken($this->csrfTokenName)->getValue());
     }
     if (null === $this->request || 'POST' !== $this->request->getRealMethod()) {
         return;
     }
     $token = new CsrfToken($this->csrfTokenName, $this->request->request->get('REQUEST_TOKEN'));
     if ($this->tokenManager->isTokenValid($token)) {
         return;
     }
     if ($this->request->isXmlHttpRequest()) {
         throw new AjaxRedirectResponseException($this->router->generate('contao_backend'));
     }
     throw new InvalidRequestTokenException('Invalid request token. Please reload the page and try again.');
 }
Ejemplo n.º 4
0
 /**
  * Request のログを出力する.
  *
  * @param Request $request
  * @return string Request のログ
  */
 protected function logRequest(Request $request)
 {
     $log = '';
     $log .= $this->logKeyValuePair('REMOTE_ADDR', $request->getClientIp());
     $log .= $this->logKeyValuePair('SCRIPT_NAME', $request->getScriptName());
     $log .= $this->logKeyValuePair('PATH_INFO', $request->getPathInfo());
     $log .= $this->logKeyValuePair('BASE_PATH', $request->getBasePath());
     $log .= $this->logKeyValuePair('BASE_URL', $request->getBaseUrl());
     $log .= $this->logKeyValuePair('SCHEME', $request->getScheme());
     $log .= $this->logKeyValuePair('REMOTE_USER', $request->getUser());
     $log .= $this->logKeyValuePair('HTTP_HOST', $request->getSchemeAndHttpHost());
     $log .= $this->logKeyValuePair('REQUEST_URI', $request->getRequestUri());
     $log .= $this->logKeyValuePair('METHOD', $request->getRealMethod());
     $log .= $this->logKeyValuePair('LOCALE', $request->getLocale());
     // $log .= $this->logArray($request->server->all(), '[server]'); // 大量にログ出力される...
     $log .= $this->logArray($request->headers->all(), '[header]');
     $log .= $this->logArray($request->query->all(), '[get]');
     $log .= $this->logArray($request->request->all(), '[post]');
     $log .= $this->logArray($request->attributes->all(), '[attributes]');
     $log .= $this->logArray($request->cookies->all(), '[cookie]');
     $log .= $this->logArray($request->files->all(), '[files]');
     return $log;
 }
Ejemplo n.º 5
0
 /**
  * @param Request $request
  * @return JsonResponse
  *
  * @Route("/{entity}/{id}", name="basic_auth", defaults={"id" = 1})
  */
 public function indexAction(Request $request)
 {
     /** @var User $user */
     $user = $this->getUser();
     return new JsonResponse(['method' => $request->getRealMethod(), 'path' => $request->getPathInfo(), 'query_params' => $request->query->all(), 'headers' => $request->headers->all(), 'content' => $this->getContent($request), 'files' => $_FILES, 'user' => ['username' => $user->getUsername(), 'password' => $user->getPassword()]]);
 }
Ejemplo n.º 6
0
 /**
  * Checks if the token check can be skipped.
  *
  * @return bool True if the token check can be skipped
  */
 private function canSkipTokenCheck()
 {
     return null === $this->request || 'POST' !== $this->request->getRealMethod() || !$this->request->attributes->has('_token_check') || false === $this->request->attributes->get('_token_check');
 }
Ejemplo n.º 7
0
 /**
  * Creates a Visitor object.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request The request of the visitor
  */
 public function __construct(Request $request)
 {
     $this->ip = $request->getClientIp();
     $this->headers = $request->headers;
     $this->method = $request->getRealMethod();
     $this->uri = $request->getRequestUri();
     $this->data = $request->request;
     $this->scheme = $request->getScheme();
     $this->protocol = $request->server->get('SERVER_PROTOCOL');
     $userAgent = $request->headers->get('user-agent');
     $this->userAgent = new UserAgent($userAgent);
     $knownBrowsers = ['msie', 'firefox', 'chrome', 'safari', 'opera', 'konqueror', 'edge', 'lynx'];
     $this->isBrowser = in_array($this->userAgent->getBrowserName(), $knownBrowsers);
 }
Ejemplo n.º 8
0
 /**
  * @param Request $request
  * @param Response $response
  * @return string
  */
 public function format(Request $request, Response $response)
 {
     return sprintf("%s %s      %s      %s <<<< %s %s      %s      %s", $request->getRealMethod(), $request->getRequestUri(), $this->formatHeaders($request->headers), $this->getContent($request), $response->getStatusCode(), Response::$statusTexts[$response->getStatusCode()], $this->formatHeaders($response->headers), $response->getContent());
 }