Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 155ecc0

Browse files
prepare new release
1 parent d2d707d commit 155ecc0

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

lib/WebService/Hexonet.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55
use warnings;
66
use WebService::Hexonet::Connector;
77

8-
our $VERSION = '1.05';
8+
our $VERSION = '1.06';
99

1010
1;
1111

lib/WebService/Hexonet/Connector.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55
use warnings;
66
use WebService::Hexonet::Connector::Connection;
77

8-
our $VERSION = '1.05';
8+
our $VERSION = '1.06';
99

1010
sub connect {
1111
return WebService::Hexonet::Connector::Connection->new(@_);

lib/WebService/Hexonet/Connector/Connection.pm

+13-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use WebService::Hexonet::Connector::Response;
66
use WebService::Hexonet::Connector::Util;
77
use LWP::UserAgent;
88

9-
our $VERSION = '1.05';
9+
our $VERSION = '1.06';
1010

1111
sub new {
1212
my $class = shift;
@@ -71,18 +71,25 @@ sub call_raw_http {
7171
}
7272
}
7373

74-
my $response = $self->{_useragent}->post( $url, $post );
75-
return $response->content();
76-
74+
my $r = $self->{_useragent}->post( $url, $post );
75+
if ( $r->is_success ) {
76+
return $r->decoded_content;
77+
}
78+
my $err = $r->status_line;
79+
return ("[RESPONSE]\r\n"
80+
. "CODE=421\r\n"
81+
. "DESCRIPTION=HTTP communication failed;$err\r\n"
82+
. "EOF\r\n" );
7783
}
7884

7985
sub _get_useragent {
8086
my $self = shift;
8187
return $self->{_useragent} if exists $self->{_useragent};
82-
$self->{_useragent} = new LWP::UserAgent(
88+
$self->{_useragent} = LWP::UserAgent->new(
8389
agent => "Hexonet-perl/$WebService::Hexonet::Connector::VERSION",
84-
keep_alive => 4
90+
keep_alive => 4,
8591
);
92+
$self->{_useragent}->default_header( 'Expect', '' );
8693
return $self->{_useragent};
8794
}
8895

lib/WebService/Hexonet/Connector/Response.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use overload
88
'@{}' => \&as_list,
99
;
1010

11-
our $VERSION = '1.05';
11+
our $VERSION = '1.06';
1212

1313
sub new {
1414
my $class = shift;

lib/WebService/Hexonet/Connector/Util.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use base 'Exporter';
77
use Time::Local;
88
use MIME::Base64;
99

10-
our $VERSION = '1.05';
10+
our $VERSION = '1.06';
1111

1212
our @EXPORT = qw();
1313
our @EXPORT_OK = qw(sqltime timesql);

t/Hexonet-connector.t

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use strict;
22
use warnings;
33

4-
use Test::More tests => 50;
4+
use Test::More;
55
use Test::Exception;
6+
use Test::RequiresInternet ( 'coreapi.1api.net' => 80 );
67

7-
our $VERSION = '1.05';
8+
our $VERSION = '1.06';
89

9-
#######################################
10+
##########################
1011
# TESTS for Connection.pm
11-
#######################################
12+
##########################
1213

1314
# T1-5: test import modules
1415
use_ok( "lib", qw(./lib) );
@@ -277,3 +278,5 @@ ok( $enc eq "ZGFzIHN0aW5rdCB6dW0gSGltbWVs" );
277278
#T50
278279
$dec = WebService::Hexonet::Connector::Util::base64_decode($enc);
279280
ok( $dec eq $key );
281+
282+
done_testing();

0 commit comments

Comments
 (0)