Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GLPI
glpi
Commits
5e18fc72
Commit
5e18fc72
authored
Jun 16, 2021
by
Curtis Conard
Committed by
Johan Cwiklinski
Jun 17, 2021
Browse files
Allow changing format with query param
parent
4dc5dc49
Changes
1
Hide whitespace changes
Inline
Side-by-side
status.php
View file @
5e18fc72
...
...
@@ -47,12 +47,25 @@ $fallback_response_type = 'text/plain';
if
(
!
isset
(
$_SERVER
[
'HTTP_ACCEPT'
])
||
!
in_array
(
$_SERVER
[
'HTTP_ACCEPT'
],
$valid_response_types
,
true
))
{
$_SERVER
[
'HTTP_ACCEPT'
]
=
$fallback_response_type
;
}
if
(
$_SERVER
[
'HTTP_ACCEPT'
]
===
'text/plain'
)
{
$format
=
$_SERVER
[
'HTTP_ACCEPT'
];
if
(
isset
(
$_REQUEST
[
'format'
]))
{
switch
(
$_REQUEST
[
'format'
])
{
case
'json'
:
$format
=
'application/json'
;
break
;
case
'plain'
:
$format
=
'text/plain'
;
break
;
}
}
if
(
$format
===
'text/plain'
)
{
Toolbox
::
deprecated
(
'Plain-text status output is deprecated please use the JSON format instead by specifically setting the Accept header to "application/json". In the future, JSON output will be the default.'
);
}
header
(
'Content-type: '
.
$
_SERVER
[
'HTTP_ACCEPT'
]
);
header
(
'Content-type: '
.
$
format
);
if
(
$
_SERVER
[
'HTTP_ACCEPT'
]
===
'application/json'
)
{
if
(
$
format
===
'application/json'
)
{
echo
json_encode
(
StatusChecker
::
getServiceStatus
(
$_REQUEST
[
'service'
]
??
null
,
true
,
true
));
}
else
{
echo
StatusChecker
::
getServiceStatus
(
$_REQUEST
[
'service'
]
??
null
,
true
,
false
);
...
...
Write
Preview
Supports
Markdown
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