Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Roman Lacko
gitlab_api
Commits
a9201805
Commit
a9201805
authored
Jan 12, 2018
by
Roman Lacko
Browse files
fix 204 No Content handling so that API does not croak on missing data
parent
94f12cea
Changes
1
Hide whitespace changes
Inline
Side-by-side
GitLab/API.pm
View file @
a9201805
...
...
@@ -229,12 +229,17 @@ sub clean_data {
croak
$response
->
message
;
}
# all responses from GitLab should be JSON data
if
(
$response
->
header
("
Content-Type
")
!~
m!^application/json!
)
{
croak
"
GitLab sent '
",
$response
->
header
("
Content-Type
"),
"
' instead of 'application/json'
";
}
# no data should be present if we got 204 No Content
return
$response
if
$response
->
code
==
HTTP_NO_CONTENT
;
# otherwise we should have gotten application/json response
croak
"
GitLab sent '
",
$response
->
header
("
Content-Type
"),
"
' instead of 'application/json'
"
if
$response
->
header
("
Content-Type
")
!~
m!^application/json!
;
return
(
$response
,
undef
)
unless
$response
->
is_success
;
# don't process data on error
return
(
$response
,
undef
)
unless
$response
->
is_success
;
my
$data
=
$response
->
decoded_content
;
utf8::
decode
(
$data
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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