Class: OpenUriAndWrite::CredentialsStore

Inherits:
Object
  • Object
show all
Defined in:
lib/open-uri-and-write/credentials_store.rb

Class Method Summary collapse

Class Method Details

.get_connection_for_url(url) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/open-uri-and-write/credentials_store.rb', line 7

def self.get_connection_for_url(url)
  hostname = URI.parse(url).host.to_s
  if(!$_webdav_credentials_pool)
    $_webdav_credentials_pool = { }
  end
  if($_webdav_credentials_pool[hostname])
    return $_webdav_credentials_pool[hostname]
  else(!$_webdav_credentials_pool[hostname])
    agent = OpenUriAndWrite::Handle.new(url, ['w'])
    $_webdav_credentials_pool[hostname] = agent.dav
    return agent.dav
  end
end