Symfony Request

Предположим пришел запрос: GET http://x.com:8000/app.php/path?foo=BAR

$request-методВозвращаетЗаметка
getUri()http://x.com:8000/app.php/path?foo=BAR 
getRequestUri()/app.php/path?foo=BAR

Удивительно, но переводит в верхний регистр символы полученные в результате применения функции urlencode(), при этом речь не идет о GET-переменных, речь просто части URL, например:

/reason/%d0%94%d1%83%d0%b1%d0%bb%d1%8c

будет возвращена как:

/reason/%D0%94%D1%83%D0%B1%D0%BB%D1%8C

похоже дело не в Symfony, дело либо в PHP, либо в Nginx, потому что нативными средствами получаемый URL имеет верхний регистр символов (хотя по факту используется нижний)

getBaseUrl()/app.php/path 
getPathInfo()/path 
getQueryString()foo=BAR 
getHttpHost()x.com:8000 
getHost()x.com 
getScheme()http 
isSecure()false 
getPort()8000 
getUriForPath('/new?foo=BAR')http://x.com:8000/app.php/new?foo=BAR 
getRelativeUriForPath('/new')../xxx 
getMethodGET 
getRealMethodGET 
getMimeTypenull 
getContentTypenull 
getContentTypeFormatnull 
getRequestFormathtml 
getDefaultLocaleen 
getLocaleen 
isMethodSafetrue 
isMethodIdempotenttrue 
isMethodCacheabletrue 
getProtocolVersionHTTP/1.1 
isXmlHttpRequestfalse 

А другие виды запросов:

$request->query->get('foo');   // similar to $_GET['foo']
$request->request->get('foo'); // similar to $_POST['foo']
$request->cookies->get('foo'); // similar to $_COOKIES['foo']
$request->files->get('foo');   // similar to $_FILES['foo']

А начиная с версии 6.3:

// the request has some POST data (e.g. `foo: bar` sent as `application/x-www-form-urlencoded`)
$request->getPayload()->all();
// returns the PHP array: ['foo' => 'bar']

// the request has body contents as some JSON-encoded data (e.g. `{"foo": "bar"}`)
$request->getPayload()->all();
// returns the JSON-decoded data as a PHP array: ['foo' => 'bar']

11.09.2021 07:08

Комментарии

Комментариев пока нет.


Copyrights © 2007 - 2026 YaPro.Ru