This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_extPart_001_01C26ED8.61FD3290
Content-Type: text/plain; charset="windows-1251"

This is what I'm currently doing to read from a URL through the company
proxy server and it's working.

    uri  RI.parse(someURL)
    
    # Get the proxy server and port.
    proxy  NV['HTTP_PROXY'] || ENV['http_proxy']
    %r{(\w+)://([\w.]+):(\d+)}.match(proxy)
    protocol, server, port  1, $2, $3
    
    # Connect through the proxy server if there is one.
    Net::HTTP::Proxy(server, port).start(uri.host) do |http|
      response  ttp.get(uri.request_uri)
      # use response.body
    end

> -----Original Message-----
> From: Alexander Bokovoy [mailto:a.bokovoy / sam-solutions.net]
> Sent: Tuesday, October 08, 2002 4:55 AM
> To: ruby-talk / ruby-lang.org
> Subject: Re: reading from a URL
> 
> 
> On Tue, Oct 08, 2002 at 03:22:07AM +0900, GOTO Kentaro wrote:
> > At Tue, 8 Oct 2002 02:33:52 +0900,
> > Volkmann, Mark <Mark.Volkmann / AGEDWARDS.com> wrote:
> > > I need to read the content of an HTTP URL.  I can break 
> the URL up into
> > > server, port and path and use Net::HTTP to read it, but 
> it seems like there
> > > should be an easier way.  I'd really like to pass the URL 
> string to a method
> > > of some class that would return an object from a class 
> that inherits from
> > > IO.  Does something like that exist?  If not, is there an 
> easier way than
> > > using Net::HTTP?
> > 
> > If you have Ruby 1.7, try
> > 
> >   require "net/http"
> >   require "uri"
> >   content  > Net::HTTP.get_print(URI.parse("http://www.example.com/index.html"))
> > 
> > If not, 
> > 
> >   require "net/http"
> >   require "uri"
> >   uri  RI.parse("http://www.example.com/index.html")
> >   content  et::HTTP.get(uri.host, uri.request_uri, uri.port)
> > 
> > Read net/http.rb if you would need http auth, redirection 
> or proxy server. 
> > This library includes the documentation of itself.  
> BTW, current Net::HTTP code does not support proxies with 
> authentication
> enabled which makes it rather unusable in corporate networks. 
> I've sent a
> patch to fix it to Matz and he forwarded it to Minero Anoki 
> (net/http.rb
> maintainer) but fix still isn't in CVS.
> 
> I'm attaching it here in meantime.
> 
> -- 
> / Alexander Bokovoy
> ---
> Q:	What is the sound of one cat napping?
> A:	Mu.
> 


***********************************************************************************
WARNING:  All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.
************************************************************************************

------_extPart_001_01C26ED8.61FD3290
Content-Type: text/html; charset="windows-1251"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: reading from a URL</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>This is what I'm currently doing to read from a URL through the company proxy server and it's working.</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; uri = URI.parse(someURL)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; # Get the proxy server and port.</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; %r{(\w+)://([\w.]+):(\d+)}.match(proxy)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; protocol, server, port = $1, $2, $3</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; # Connect through the proxy server ifhere is one.</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Net::<A HREF="HTTP::Proxy(server" TARGET="_blank">HTTP::Proxy(server</A>, port).start(uri.host) do |http|</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response = http.get(uri.request_uri)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # use response.body</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; end</FONT>
</P>

<P><FONT SIZE=2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt; From: Alexander Bokovoy [mailto:a.bokovoy / sam-solutions.net]</FONT>
<BR><FONT SIZE=2>&gt; Sent: Tuesday, October 08, 2002 4:55 AM</FONT>
<BR><FONT SIZE=2>&gt; To: ruby-talk / ruby-lang.org</FONT>
<BR><FONT SIZE=2>&gt; Subject: Re: reading from a URL</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; On Tue, Oct 08, 2002 at 03:22:07AM +0900, GOTO Kentaro wrote:</FONT>
<BR><FONT SIZE=2>&gt; &gt; At Tue, 8 Oct 2002 02:33:52 +0900,</FONT>
<BR><FONT SIZE=2>&gt; &gt; Volkmann, Mark &lt;Mark.Volkmann / AGEDWARDS.com&gt; wrote:</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; I need to read the content of an HTTP URL.&nbsp; I can break </FONT>
<BR><FONT SIZE=2>&gt; the URL up into</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; server, port and path and use Net::HTTP to read it, but </FONT>
<BR><FONT SIZE=2>&gt; it seems like there</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; should be an easier way.&nbsp; I'd reallyike to pass the URL </FONT>
<BR><FONT SIZE=2>&gt; string to a method</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; of some class that would return an objectrom a class </FONT>
<BR><FONT SIZE=2>&gt; that inherits from</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; IO.&nbsp; Does something like that exist?&nbsp; If not, is there an </FONT>
<BR><FONT SIZE=2>&gt; easier way than</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; using Net::HTTP?</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; If you have Ruby 1.7, try</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt;&nbsp;&nbsp; require &quot;net/http&quot;</FONT>
<BR><FONT SIZE=2>&gt; &gt;&nbsp;&nbsp; require &quot;uri&quot;</FONT>
<BR><FONT SIZE=2>&gt; &gt;&nbsp;&nbsp; content = </FONT>
<BR><FONT SIZE=2>&gt; Net::HTTP.get_print(URI.parse(&quot;<A HREF="http://www.example.com/index.html" TARGET="_blank">http://www.example.com/index.html</A>&quot;))</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; If not, </FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt;&nbsp;&nbsp; require &quot;net/http&quot;</FONT>
<BR><FONT SIZE=2>&gt; &gt;&nbsp;&nbsp; require &quot;uri&quot;</FONT>
<BR><FONT SIZE=2>&gt; &gt;&nbsp;&nbsp; uri = URI.parse(&quot;<A HREF="http://www.example.com/index.html" TARGET="_blank">http://www.example.com/index.html</A>&quot;)</FONT>
<BR><FONT SIZE=2>&gt; &gt;&nbsp;&nbsp; content = Net::HTTP.get(uri.host, uri.request_uri, uri.port)</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; Read net/http.rb if you would need http auth, redirection </FONT>
<BR><FONT SIZE=2>&gt; or proxy server. </FONT>
<BR><FONT SIZE=2>&gt; &gt; This library includes the documentation of itself.&nbsp; </FONT>
<BR><FONT SIZE=2>&gt; BTW, current Net::HTTP code does not support proxies with </FONT>
<BR><FONT SIZE=2>&gt; authentication</FONT>
<BR><FONT SIZE=2>&gt; enabled which makes it rather unusable in corporateetworks. </FONT>
<BR><FONT SIZE=2>&gt; I've sent a</FONT>
<BR><FONT SIZE=2>&gt; patch to fix it to Matz and he forwarded it to Minero Anoki </FONT>
<BR><FONT SIZE=2>&gt; (net/http.rb</FONT>
<BR><FONT SIZE=2>&gt; maintainer) but fix still isn't in CVS.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; I'm attaching it here in meantime.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; -- </FONT>
<BR><FONT SIZE=2>&gt; / Alexander Bokovoy</FONT>
<BR><FONT SIZE=2>&gt; ---</FONT>
<BR><FONT SIZE=2>&gt; Q:&nbsp;&nbsp;&nbsp; What is the sound of one cat napping?</FONT>
<BR><FONT SIZE=2>&gt; A:&nbsp;&nbsp;&nbsp; Mu.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
</P>

<CODE><FONT SIZE=3><BR>
<BR>
***********************************************************************************<BR>
WARNING:  All e-mail sent to and from this address will be received or<BR>
otherwise recorded by the A.G. Edwards corporate e-mail system and is<BR>
subject to archival, monitoring or review by, and/or disclosure to,<BR>
someone other than the recipient.<BR>
************************************************************************************<BR>
</FONT></CODE></BODY>
</HTML>
------_extPart_001_01C26ED8.61FD3290--