lib/em-ftp-client/control_connection.rb
# Called when a response for the PASV verb is received
#
# Opens a new data connection and executes the callback
Called when a response for the PASV verb is received
Opens a new data connection and executes the callback
Called when a response for the PASV verb is received Opens a new data connection and executes the callback
def pasv_response(response, data_connection)
        @responder = nil
        if response.code == "227"
          if m = /(\d{1,3},\d{1,3},\d{1,3},\d{1,3}),(\d+),(\d+)/.match(response.body)
            @response = Response.new
            host_ip = m[1].gsub(",", ".")
            host_port = m[2].to_i*256 + m[3].to_i
            pasv_callback = @callback
            @data_connection = EM.connect(host_ip, host_port, DataConnection)
            @data_connection.on_connect &pasv_callback
            @data_connection.callback {|data| data_connection_closed(data) }
          end
        end
      end
def pasv_response ( response , data_connection ) @responder = nil if response . code == "227" if m = / ( \d {1,3}, \d {1,3}, \d {1,3}, \d {1,3}),( \d +),( \d +) / . match ( response . body ) @response = Response . new host_ip = m [ 1 ] . gsub ( "," , "." ) host_port = m [ 2 ] . to_i * 256 + m [ 3 ] . to_i pasv_callback = @callback @data_connection = EM . connect ( host_ip , host_port , DataConnection ) @data_connection . on_connect & pasv_callback @data_connection . callback { | data | data_connection_closed ( data ) } end end end
Called when a response for the PASV verb is received
Opens a new data connection and executes the callback
Called when a response for the PASV verb is received Opens a new data connection and executes the callback
# Create a new response for handling the next request on the control connection, since # currently @response is the response to pasv, and if the data connection completes # before the next control request, data_connection_closed must not use the pasv # response to check if the control response is complete (but get/list/etc response)
response
data_connection