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
3434f6d4
Commit
3434f6d4
authored
Mar 03, 2017
by
Roman Lacko
Browse files
fixed infinite loop for empty response in GitLab::API::Iterator
parent
0da27679
Changes
1
Hide whitespace changes
Inline
Side-by-side
GitLab/API/Iterator.pm
View file @
3434f6d4
...
...
@@ -148,28 +148,28 @@ sub next_block {
return
0
;
}
if
(
!
defined
$self
->
{
pages_total
})
{
$self
->
{
pages_total
}
=
$response
->
header
("
X-Total-Pages
");
}
croak
"
Response for
"
.
$self
->
name
.
"
did not contain an array
"
unless
ref
$data
eq
"
ARRAY
";
#
if there was no X-Total-Pages, the response is not paginated, blame
the
us
er
#
get total number of pages from
the
head
er
if
(
!
defined
$self
->
{
pages_total
})
{
# some requests are not paginated if additional parameters are provided
# carp "Iterating over non-paginated request for " . $self->name;
$self
->
{
pages_total
}
=
1
;
# use 1 if there are data, 0 otherwise
my
$default
=
@$data
?
1
:
0
;
$self
->
{
pages_total
}
=
$response
->
header
("
X-Total-Pages
")
//
$default
;
$self
->
idebug
("
total pages
$self
->{pages_total}
");
}
croak
"
Response for
"
.
$self
->
name
.
"
did not contain an array
"
unless
ref
$data
eq
"
ARRAY
";
push
@
{
$self
->
{
data
}},
@$data
;
push
@
{
$self
->
{
responses
}},
$response
;
$self
->
api
->
{
last
}
=
$response
;
$self
->
{
count
}
+=
scalar
@$data
;
++
$self
->
{
pages_read
};
$self
->
api
->
{
last
}
=
$response
;
$self
->
{
count
}
+=
scalar
@$data
;
# only increase read pages if there are pages to read
++
$self
->
{
pages_read
}
if
$self
->
{
pages_total
};
$self
->
{
finished
}
=
$self
->
{
pages_read
}
==
$self
->
{
pages_total
};
$self
->
{
finished
}
=
!
$self
->
{
pages_total
}
||
$self
->
{
pages_read
}
==
$self
->
{
pages_total
};
$self
->
idebug
("
block read successful
");
$self
->
idebug
("
all blocks were read
")
if
$self
->
{
finished
};
return
1
;
...
...
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