Lines 174-182
sub harvest_sushi {
Link Here
|
174 |
$self->{begin_date} = $args->{begin_date}; |
174 |
$self->{begin_date} = $args->{begin_date}; |
175 |
$self->{end_date} = $args->{end_date}; |
175 |
$self->{end_date} = $args->{end_date}; |
176 |
my $url = $self->_build_url_query; |
176 |
my $url = $self->_build_url_query; |
177 |
my $request = HTTP::Request->new( 'GET' => $url ); |
177 |
my $response = _handle_sushi_request($url); |
178 |
my $ua = LWP::UserAgent->new; |
|
|
179 |
my $response = $ua->simple_request($request); |
180 |
|
178 |
|
181 |
if ( $response->code >= 400 ) { |
179 |
if ( $response->code >= 400 ) { |
182 |
my $result = decode_json( $response->decoded_content ); |
180 |
my $result = decode_json( $response->decoded_content ); |
Lines 277-285
sub test_connection {
Link Here
|
277 |
$url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id; |
275 |
$url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id; |
278 |
$url .= '&api_key=' . $self->api_key if $self->api_key; |
276 |
$url .= '&api_key=' . $self->api_key if $self->api_key; |
279 |
|
277 |
|
280 |
my $request = HTTP::Request->new( 'GET' => $url ); |
278 |
my $response = _handle_sushi_request($url); |
281 |
my $ua = LWP::UserAgent->new; |
|
|
282 |
my $response = $ua->simple_request($request); |
283 |
|
279 |
|
284 |
if ( $response->{_rc} >= 400 ) { |
280 |
if ( $response->{_rc} >= 400 ) { |
285 |
my $message = $response->{_msg}; |
281 |
my $message = $response->{_msg}; |
Lines 517-522
sub _counter_file_size_too_large {
Link Here
|
517 |
return 0; |
513 |
return 0; |
518 |
} |
514 |
} |
519 |
|
515 |
|
|
|
516 |
=head3 _handle_sushi_response |
517 |
|
518 |
Creates and sends the request based on a provided url |
519 |
Also handles any redirects |
520 |
|
521 |
=cut |
522 |
|
523 |
sub _handle_sushi_request { |
524 |
my ($url) = @_; |
525 |
|
526 |
my $request = HTTP::Request->new( 'GET' => $url ); |
527 |
my $ua = LWP::UserAgent->new; |
528 |
$ua->agent( 'Koha/' . Koha::version() ); |
529 |
my $response = $ua->simple_request($request); |
530 |
|
531 |
if ( $response->is_redirect ) { |
532 |
my $redirect_url = $response->header('Location'); |
533 |
$redirect_url = URI->new_abs( $redirect_url, $url ); |
534 |
$response = $ua->get($redirect_url); |
535 |
} |
536 |
|
537 |
return $response; |
538 |
} |
539 |
|
520 |
=head3 _type |
540 |
=head3 _type |
521 |
|
541 |
|
522 |
=cut |
542 |
=cut |
523 |
- |
|
|