Class: KonoEppClient::Transport::HttpTransport

Inherits:
Object
  • Object
show all
Includes:
KonoEppClient::Transport
Defined in:
lib/epp/transport/http.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, port) ⇒ HttpTransport

Returns a new instance of HttpTransport.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/epp/transport/http.rb', line 9

def initialize( server, port )
  @net_http = Net::HTTP.new( server, port )

  @net_http.use_ssl = true
  @net_http.ssl_version = :TLSv1
  @net_http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  
  #FIXME: Commented because not work on MacOS (dev machine), is necessary for Linux machine?
  #@net_http.ca_path = '/etc/ssl/certs' 
  
  # @net_http.set_debug_output $stderr
   #@net_http.set_debug_output File.open( "/tmp/net.log", "a")

  @store = PStore.new( "cookies.pstore" )
end

Instance Method Details

#closeObject



45
46
# File 'lib/epp/transport/http.rb', line 45

def close
end

#readObject



25
26
27
28
# File 'lib/epp/transport/http.rb', line 25

def read
  #puts @response.body
  @response.body
end

#write(xml) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/epp/transport/http.rb', line 30

def write( xml )
  @store.transaction do
    cookie_str = '$Version="1"'
    @store[:cookies].each do |c|
      cookie_str += "; #{c[:name]}=#{c[:value]}"
    end if @store[:cookies]

    header = { "Cookie" => cookie_str }

    @response = @net_http.post( "/", xml, header )

    @store[:cookies] = parse_set_cookie( @response["Set-Cookie"] ) if @response["Set-Cookie"]
  end
end