File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/HTTP.pm
Criterion Covered Total %
statement 24 40 60.0
branch 0 4 0.0
condition 0 3 0.0
subroutine 8 12 66.6
pod 0 4 0.0
total 32 63 50.7


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, EPP over HTTP/HTTPS Connection handling
2             ##
3             ## Copyright (c) 2008-2010,2013 Patrick Mevzek . All rights reserved.
4             ##
5             ## This file is part of Net::DRI
6             ##
7             ## Net::DRI is free software; you can redistribute it and/or modify
8             ## it under the terms of the GNU General Public License as published by
9             ## the Free Software Foundation; either version 2 of the License, or
10             ## (at your option) any later version.
11             ##
12             ## See the LICENSE file that comes with this distribution for more details.
13             ####################################################################################################
14              
15             package Net::DRI::Protocol::EPP::Extensions::HTTP;
16              
17 1     1   968 use strict;
  1         1  
  1         24  
18 1     1   3 use warnings;
  1         1  
  1         21  
19              
20 1     1   2 use base qw/Net::DRI::Protocol::EPP::Connection/;
  1         1  
  1         344  
21              
22 1     1   5 use HTTP::Request ();
  1         1  
  1         12  
23              
24 1     1   3 use Net::DRI::Util;
  1         1  
  1         15  
25 1     1   2 use Net::DRI::Exception;
  1         1  
  1         13  
26 1     1   2 use Net::DRI::Data::Raw;
  1         1  
  1         4  
27 1     1   19 use Net::DRI::Protocol::ResultStatus;
  1         0  
  1         8  
28              
29             =pod
30              
31             =head1 NAME
32              
33             Net::DRI::Protocol::EPP::Extensions::HTTP - EPP over HTTP/HTTPS connection handling for Net::DRI
34              
35             =head1 DESCRIPTION
36              
37             Please see the README file for details.
38              
39             =head1 SUPPORT
40              
41             For now, support questions should be sent to:
42              
43             Enetdri@dotandco.comE
44              
45             Please also see the SUPPORT file in the distribution.
46              
47             =head1 SEE ALSO
48              
49             Ehttp://www.dotandco.com/services/software/Net-DRI/E
50              
51             =head1 AUTHOR
52              
53             Patrick Mevzek, Enetdri@dotandco.comE
54              
55             =head1 COPYRIGHT
56              
57             Copyright (c) 2008-2010,2013 Patrick Mevzek .
58             All rights reserved.
59              
60             This program is free software; you can redistribute it and/or modify
61             it under the terms of the GNU General Public License as published by
62             the Free Software Foundation; either version 2 of the License, or
63             (at your option) any later version.
64              
65             See the LICENSE file that comes with this distribution for more details.
66              
67             =cut
68              
69             ####################################################################################################
70              
71             sub init
72             {
73 0     0 0   my ($class,$to)=@_;
74 0           my $t=$to->transport_data();
75              
76 0           foreach my $p (qw/client_login client_password remote_url/)
77             {
78 0 0 0       Net::DRI::Exception::usererr_insufficient_parameters($p.' must be defined') unless (exists($t->{$p}) && $t->{$p});
79             }
80 0           return;
81             }
82              
83             sub greeting
84             {
85 0     0 0   my ($class,$cm)=@_;
86 0           return $class->keepalive($cm); ## will send an message, which is in fact a greeting !
87             }
88              
89             ####################################################################################################
90              
91             sub read_data
92             {
93 0     0 0   my ($class,$to,$res)=@_;
94 0 0         die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_FAILED_CLOSING',sprintf('Got unsuccessfull HTTP response: %d %s',$res->code(),$res->message()),'en')) unless $res->is_success();
95 0           return Net::DRI::Data::Raw->new_from_xmlstring($res->decoded_content());
96             }
97              
98             sub write_message
99             {
100 0     0 0   my ($class,$to,$msg)=@_;
101 0           my $t=$to->transport_data();
102 0           my $req=HTTP::Request->new('POST',$t->{remote_url});
103 0           $req->header('Content-Type','text/xml');
104 0           $req->content(Net::DRI::Util::encode_utf8($msg));
105             ## Content-Length will be automatically computed during Transport by LWP::UserAgent
106 0           return $req;
107             }
108              
109             ####################################################################################################
110             1;