<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>connection_for (Gem::RemoteFetcher)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/rubygems/remote_fetcher.rb, line 230</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">connection_for</span>(<span class="ruby-identifier">uri</span>)
    <span class="ruby-identifier">net_http_args</span> = [<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>]

    <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@proxy_uri</span> <span class="ruby-keyword kw">then</span>
      <span class="ruby-identifier">net_http_args</span> <span class="ruby-operator">+=</span> [
        <span class="ruby-ivar">@proxy_uri</span>.<span class="ruby-identifier">host</span>,
        <span class="ruby-ivar">@proxy_uri</span>.<span class="ruby-identifier">port</span>,
        <span class="ruby-ivar">@proxy_uri</span>.<span class="ruby-identifier">user</span>,
        <span class="ruby-ivar">@proxy_uri</span>.<span class="ruby-identifier">password</span>
      ]
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-identifier">connection_id</span> = <span class="ruby-identifier">net_http_args</span>.<span class="ruby-identifier">join</span> <span class="ruby-value str">':'</span>
    <span class="ruby-ivar">@connections</span>[<span class="ruby-identifier">connection_id</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">net_http_args</span>)
    <span class="ruby-identifier">connection</span> = <span class="ruby-ivar">@connections</span>[<span class="ruby-identifier">connection_id</span>]

    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'https'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">connection</span>.<span class="ruby-identifier">started?</span> <span class="ruby-keyword kw">then</span>
      <span class="ruby-identifier">require</span> <span class="ruby-value str">'net/https'</span>
      <span class="ruby-identifier">connection</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">true</span>
      <span class="ruby-identifier">connection</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-identifier">connection</span>.<span class="ruby-identifier">start</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">connection</span>.<span class="ruby-identifier">started?</span>

    <span class="ruby-identifier">connection</span>
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>