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