Professional Web Applications Themes

open-uri and proxies - Ruby

I was trying to play with open-uri as shown on Whytheluckystiff's What's Shiny and new in Ruby 1.8 article: require 'open-uri' require 'yaml' open( "http://www.whytheluckystiff.net/why.yml" ) do |f| feed = YAML::load( f ) end But I'm behind a firewall and need to use a proxy to get out. Any way to use proxies with open-uri? Phil...

  1. #1

    Default open-uri and proxies

    I was trying to play with open-uri as shown on Whytheluckystiff's
    What's Shiny and new in Ruby 1.8 article:

    require 'open-uri'
    require 'yaml'

    open( "http://www.whytheluckystiff.net/why.yml" ) do |f|
    feed = YAML::load( f )
    end


    But I'm behind a firewall and need to use a proxy to get out. Any way
    to use proxies with open-uri?

    Phil
    Phil Guest

  2. #2

    Default Re: open-uri and proxies

    Phil:

    you can try setting your proxy via Env variable.

    export HTTP_PROXY=your.proxy.goes.here


    I'm also behind a firewall, I tried it, the proxy was taken from the env var but I got the following error:

    usr/local/bin/lib/ruby/1.8/open-uri.rb:143:in `open_loop': undefined method `proxy_open' for #<URI::Generic:0x200c61c0 URL:http-myproxy.com> (NoMethodError)
    from /usr/local/bin/lib/ruby/1.8/open-uri.rb:105:in `open_uri'
    from /usr/local/bin/lib/ruby/1.8/open-uri.rb:74:in `open'
    from 2.rb:4

    p "?"


    -Ronnie.

    Phil Tomson wrote:
     





    Bermejo, Guest

  3. #3

    Default Re: open-uri and proxies

    com (Phil Tomson) wrote in message news:<google.com>... 

    Found the recipe, here it is if you need it:

    open("http://www.ruby-lang.org",:proxy=>"http://your.proxy.here:8080") do |f|
    f.each_line {|line| p line }
    end


    Phil
    Phil Guest

Similar Threads

  1. Coldfusion and proxies
    By WhiteClaw48 in forum Coldfusion Server Administration
    Replies: 0
    Last Post: March 20th, 04:05 PM
  2. Generating proxies in VS2005
    By Steve in forum ASP.NET Web Services
    Replies: 6
    Last Post: June 12th, 03:49 PM
  3. Webservice Proxies With VS.net
    By Dave in forum ASP.NET Web Services
    Replies: 1
    Last Post: October 13th, 08:49 PM
  4. some proxies post and some won't with lwp
    By Robert in forum PERL Miscellaneous
    Replies: 7
    Last Post: September 24th, 08:23 AM
  5. Help with cache-proxies
    By desa15@necso.es in forum PHP Development
    Replies: 0
    Last Post: July 25th, 09:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139