Commit a9201805 authored by Roman Lacko's avatar Roman Lacko
Browse files

fix 204 No Content handling so that API does not croak on missing data

parent 94f12cea
......@@ -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;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment