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
b1342a59
Commit
b1342a59
authored
Jul 06, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring the Request class.
parent
af7ba046
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
25 deletions
+21
-25
request.php
system/request.php
+21
-25
No files found.
system/request.php
View file @
b1342a59
...
@@ -35,46 +35,42 @@ class Request {
...
@@ -35,46 +35,42 @@ class Request {
elseif
(
isset
(
$_SERVER
[
'REQUEST_URI'
]))
elseif
(
isset
(
$_SERVER
[
'REQUEST_URI'
]))
{
{
$uri
=
parse_url
(
$_SERVER
[
'REQUEST_URI'
],
PHP_URL_PATH
);
$uri
=
parse_url
(
$_SERVER
[
'REQUEST_URI'
],
PHP_URL_PATH
);
if
(
$uri
===
false
)
{
throw
new
\Exception
(
"Malformed request URI. Request terminated."
);
}
}
}
else
else
{
{
throw
new
\Exception
(
'Unable to determine the request URI.'
);
throw
new
\Exception
(
'Unable to determine the request URI.'
);
}
}
// -------------------------------------------------------
if
(
$uri
===
false
)
// Remove the application URL.
// -------------------------------------------------------
$base_url
=
parse_url
(
Config
::
get
(
'application.url'
),
PHP_URL_PATH
);
if
(
strpos
(
$uri
,
$base_url
)
===
0
)
{
{
$uri
=
(
string
)
substr
(
$uri
,
strlen
(
$base_url
)
);
throw
new
\Exception
(
"Malformed request URI. Request terminated."
);
}
}
// -------------------------------------------------------
$uri
=
static
::
remove_from_uri
(
$uri
,
parse_url
(
Config
::
get
(
'application.url'
),
PHP_URL_PATH
));
// Remove the application index and any extra slashes.
$uri
=
static
::
remove_from_uri
(
$uri
,
'/'
.
Config
::
get
(
'application.index'
));
// -------------------------------------------------------
$index
=
Config
::
get
(
'application.index'
);
if
(
strpos
(
$uri
,
'/'
.
$index
)
===
0
)
{
$uri
=
(
string
)
substr
(
$uri
,
strlen
(
'/'
.
$index
));
}
$uri
=
trim
(
$uri
,
'/'
);
$uri
=
trim
(
$uri
,
'/'
);
// -------------------------------------------------------
// If the requests is to the root of the application, we
// always return a single forward slash.
// -------------------------------------------------------
return
(
$uri
==
''
)
?
'/'
:
strtolower
(
$uri
);
return
(
$uri
==
''
)
?
'/'
:
strtolower
(
$uri
);
}
}
/**
* Remove a string from the beginning of a URI.
*
* @param string $uri
* @param string $value
* @return string
*/
private
static
function
remove_from_uri
(
$uri
,
$value
)
{
if
(
strpos
(
$uri
,
$value
)
===
0
)
{
$uri
=
(
string
)
substr
(
$uri
,
strlen
(
$value
));
}
return
$uri
;
}
/**
/**
* Get the request method.
* Get the request method.
*
*
...
...
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