Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
bcd3bd85
Commit
bcd3bd85
authored
Mar 29, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding header support.
parent
730808fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
20 deletions
+34
-20
request.php
laravel/request.php
+34
-20
No files found.
laravel/request.php
View file @
bcd3bd85
...
@@ -21,7 +21,7 @@ class Request {
...
@@ -21,7 +21,7 @@ class Request {
*
*
* @var string
* @var string
*/
*/
const
spoofer
=
'_
_spoofer
'
;
const
spoofer
=
'_
method
'
;
/**
/**
* Get the URI for the current request.
* Get the URI for the current request.
...
@@ -40,12 +40,36 @@ class Request {
...
@@ -40,12 +40,36 @@ class Request {
*/
*/
public
static
function
method
()
public
static
function
method
()
{
{
if
(
$_SERVER
[
'REQUEST_METHOD'
]
==
'HEAD'
)
$method
=
static
::
foundation
()
->
getMethod
();
{
return
'GET'
;
}
return
(
static
::
spoofed
())
?
$_POST
[
Request
::
spoofer
]
:
$_SERVER
[
'REQUEST_METHOD'
];
return
(
$method
==
'HEAD'
)
?
'GET'
:
$method
;
}
/**
* Get a header from the request.
*
* <code>
* // Get a header from the request
* $referer = Request::header('referer');
* </code>
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public
static
function
header
(
$key
,
$default
=
null
)
{
return
array_get
(
static
::
foundation
()
->
headers
->
all
(),
$key
,
$default
);
}
/**
* Get all of the HTTP request headers.
*
* @return array
*/
public
static
function
headers
()
{
return
static
::
foundation
()
->
headers
->
all
();
}
}
/**
/**
...
@@ -57,7 +81,7 @@ class Request {
...
@@ -57,7 +81,7 @@ class Request {
*/
*/
public
static
function
server
(
$key
=
null
,
$default
=
null
)
public
static
function
server
(
$key
=
null
,
$default
=
null
)
{
{
return
array_get
(
$_SERVER
,
strtoupper
(
$key
)
,
$default
);
return
array_get
(
static
::
foundation
()
->
server
->
all
(),
$key
,
$default
);
}
}
/**
/**
...
@@ -67,7 +91,7 @@ class Request {
...
@@ -67,7 +91,7 @@ class Request {
*/
*/
public
static
function
spoofed
()
public
static
function
spoofed
()
{
{
return
is_array
(
$_POST
)
and
array_key_exists
(
Request
::
spoofer
,
$_POST
);
return
!
is_null
(
static
::
foundation
()
->
get
(
Request
::
spoofer
)
);
}
}
/**
/**
...
@@ -81,16 +105,6 @@ class Request {
...
@@ -81,16 +105,6 @@ class Request {
return
value
(
static
::
foundation
()
->
getClientIp
(),
$default
);
return
value
(
static
::
foundation
()
->
getClientIp
(),
$default
);
}
}
/**
* Get the HTTP protocol for the request.
*
* @return string
*/
public
static
function
protocol
()
{
return
array_get
(
$_SERVER
,
'SERVER_PROTOCOL'
,
'HTTP/1.1'
);
}
/**
/**
* Get the list of acceptable content types for the request.
* Get the list of acceptable content types for the request.
*
*
...
@@ -150,7 +164,7 @@ class Request {
...
@@ -150,7 +164,7 @@ class Request {
*/
*/
public
static
function
referrer
()
public
static
function
referrer
()
{
{
return
array_get
(
$_SERVER
,
'HTTP_REFERER
'
);
return
static
::
foundation
()
->
headers
->
get
(
'referer
'
);
}
}
/**
/**
...
@@ -170,7 +184,7 @@ class Request {
...
@@ -170,7 +184,7 @@ class Request {
*/
*/
public
static
function
env
()
public
static
function
env
()
{
{
if
(
isset
(
$_SERVER
[
'LARAVEL_ENV'
]))
return
$_SERVER
[
'LARAVEL_ENV'
]
;
return
static
::
foundation
()
->
server
->
get
(
'LARAVEL_ENV'
)
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment