Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: open-uri.rb
require 'uri'
[0] Fix | Delete
require 'stringio'
[1] Fix | Delete
require 'time'
[2] Fix | Delete
[3] Fix | Delete
module Kernel
[4] Fix | Delete
private
[5] Fix | Delete
alias open_uri_original_open open # :nodoc:
[6] Fix | Delete
[7] Fix | Delete
# makes possible to open various resources including URIs.
[8] Fix | Delete
# If the first argument respond to `open' method,
[9] Fix | Delete
# the method is called with the rest arguments.
[10] Fix | Delete
#
[11] Fix | Delete
# If the first argument is a string which begins with xxx://,
[12] Fix | Delete
# it is parsed by URI.parse. If the parsed object respond to `open' method,
[13] Fix | Delete
# the method is called with the rest arguments.
[14] Fix | Delete
#
[15] Fix | Delete
# Otherwise original open is called.
[16] Fix | Delete
#
[17] Fix | Delete
# Since open-uri.rb provides URI::HTTP#open, URI::HTTPS#open and
[18] Fix | Delete
# URI::FTP#open,
[19] Fix | Delete
# Kernel[#.]open can accepts such URIs and strings which begins with
[20] Fix | Delete
# http://, https:// and ftp://.
[21] Fix | Delete
# In these case, the opened file object is extended by OpenURI::Meta.
[22] Fix | Delete
def open(name, *rest, &block) # :doc:
[23] Fix | Delete
if name.respond_to?(:open)
[24] Fix | Delete
name.open(*rest, &block)
[25] Fix | Delete
elsif name.respond_to?(:to_str) &&
[26] Fix | Delete
%r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name &&
[27] Fix | Delete
(uri = URI.parse(name)).respond_to?(:open)
[28] Fix | Delete
uri.open(*rest, &block)
[29] Fix | Delete
else
[30] Fix | Delete
open_uri_original_open(name, *rest, &block)
[31] Fix | Delete
end
[32] Fix | Delete
end
[33] Fix | Delete
module_function :open
[34] Fix | Delete
end
[35] Fix | Delete
[36] Fix | Delete
# OpenURI is an easy-to-use wrapper for net/http, net/https and net/ftp.
[37] Fix | Delete
#
[38] Fix | Delete
#== Example
[39] Fix | Delete
#
[40] Fix | Delete
# It is possible to open http/https/ftp URL as usual like opening a file:
[41] Fix | Delete
#
[42] Fix | Delete
# open("http://www.ruby-lang.org/") {|f|
[43] Fix | Delete
# f.each_line {|line| p line}
[44] Fix | Delete
# }
[45] Fix | Delete
#
[46] Fix | Delete
# The opened file has several methods for meta information as follows since
[47] Fix | Delete
# it is extended by OpenURI::Meta.
[48] Fix | Delete
#
[49] Fix | Delete
# open("http://www.ruby-lang.org/en") {|f|
[50] Fix | Delete
# f.each_line {|line| p line}
[51] Fix | Delete
# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
[52] Fix | Delete
# p f.content_type # "text/html"
[53] Fix | Delete
# p f.charset # "iso-8859-1"
[54] Fix | Delete
# p f.content_encoding # []
[55] Fix | Delete
# p f.last_modified # Thu Dec 05 02:45:02 UTC 2002
[56] Fix | Delete
# }
[57] Fix | Delete
#
[58] Fix | Delete
# Additional header fields can be specified by an optional hash argument.
[59] Fix | Delete
#
[60] Fix | Delete
# open("http://www.ruby-lang.org/en/",
[61] Fix | Delete
# "User-Agent" => "Ruby/#{RUBY_VERSION}",
[62] Fix | Delete
# "From" => "foo@bar.invalid",
[63] Fix | Delete
# "Referer" => "http://www.ruby-lang.org/") {|f|
[64] Fix | Delete
# # ...
[65] Fix | Delete
# }
[66] Fix | Delete
#
[67] Fix | Delete
# The environment variables such as http_proxy, https_proxy and ftp_proxy
[68] Fix | Delete
# are in effect by default. :proxy => nil disables proxy.
[69] Fix | Delete
#
[70] Fix | Delete
# open("http://www.ruby-lang.org/en/raa.html", :proxy => nil) {|f|
[71] Fix | Delete
# # ...
[72] Fix | Delete
# }
[73] Fix | Delete
#
[74] Fix | Delete
# URI objects can be opened in a similar way.
[75] Fix | Delete
#
[76] Fix | Delete
# uri = URI.parse("http://www.ruby-lang.org/en/")
[77] Fix | Delete
# uri.open {|f|
[78] Fix | Delete
# # ...
[79] Fix | Delete
# }
[80] Fix | Delete
#
[81] Fix | Delete
# URI objects can be read directly. The returned string is also extended by
[82] Fix | Delete
# OpenURI::Meta.
[83] Fix | Delete
#
[84] Fix | Delete
# str = uri.read
[85] Fix | Delete
# p str.base_uri
[86] Fix | Delete
#
[87] Fix | Delete
# Author:: Tanaka Akira <akr@m17n.org>
[88] Fix | Delete
[89] Fix | Delete
module OpenURI
[90] Fix | Delete
Options = {
[91] Fix | Delete
:proxy => true,
[92] Fix | Delete
:progress_proc => true,
[93] Fix | Delete
:content_length_proc => true,
[94] Fix | Delete
:http_basic_authentication => true,
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
def OpenURI.check_options(options) # :nodoc:
[98] Fix | Delete
options.each {|k, v|
[99] Fix | Delete
next unless Symbol === k
[100] Fix | Delete
unless Options.include? k
[101] Fix | Delete
raise ArgumentError, "unrecognized option: #{k}"
[102] Fix | Delete
end
[103] Fix | Delete
}
[104] Fix | Delete
end
[105] Fix | Delete
[106] Fix | Delete
def OpenURI.scan_open_optional_arguments(*rest) # :nodoc:
[107] Fix | Delete
if !rest.empty? && (String === rest.first || Integer === rest.first)
[108] Fix | Delete
mode = rest.shift
[109] Fix | Delete
if !rest.empty? && Integer === rest.first
[110] Fix | Delete
perm = rest.shift
[111] Fix | Delete
end
[112] Fix | Delete
end
[113] Fix | Delete
return mode, perm, rest
[114] Fix | Delete
end
[115] Fix | Delete
[116] Fix | Delete
def OpenURI.open_uri(name, *rest) # :nodoc:
[117] Fix | Delete
uri = URI::Generic === name ? name : URI.parse(name)
[118] Fix | Delete
mode, perm, rest = OpenURI.scan_open_optional_arguments(*rest)
[119] Fix | Delete
options = rest.shift if !rest.empty? && Hash === rest.first
[120] Fix | Delete
raise ArgumentError.new("extra arguments") if !rest.empty?
[121] Fix | Delete
options ||= {}
[122] Fix | Delete
OpenURI.check_options(options)
[123] Fix | Delete
[124] Fix | Delete
unless mode == nil ||
[125] Fix | Delete
mode == 'r' || mode == 'rb' ||
[126] Fix | Delete
mode == File::RDONLY
[127] Fix | Delete
raise ArgumentError.new("invalid access mode #{mode} (#{uri.class} resource is read only.)")
[128] Fix | Delete
end
[129] Fix | Delete
[130] Fix | Delete
io = open_loop(uri, options)
[131] Fix | Delete
if block_given?
[132] Fix | Delete
begin
[133] Fix | Delete
yield io
[134] Fix | Delete
ensure
[135] Fix | Delete
io.close
[136] Fix | Delete
end
[137] Fix | Delete
else
[138] Fix | Delete
io
[139] Fix | Delete
end
[140] Fix | Delete
end
[141] Fix | Delete
[142] Fix | Delete
def OpenURI.open_loop(uri, options) # :nodoc:
[143] Fix | Delete
case opt_proxy = options.fetch(:proxy, true)
[144] Fix | Delete
when true
[145] Fix | Delete
find_proxy = lambda {|u| u.find_proxy}
[146] Fix | Delete
when nil, false
[147] Fix | Delete
find_proxy = lambda {|u| nil}
[148] Fix | Delete
when String
[149] Fix | Delete
opt_proxy = URI.parse(opt_proxy)
[150] Fix | Delete
find_proxy = lambda {|u| opt_proxy}
[151] Fix | Delete
when URI::Generic
[152] Fix | Delete
find_proxy = lambda {|u| opt_proxy}
[153] Fix | Delete
else
[154] Fix | Delete
raise ArgumentError.new("Invalid proxy option: #{opt_proxy}")
[155] Fix | Delete
end
[156] Fix | Delete
[157] Fix | Delete
uri_set = {}
[158] Fix | Delete
buf = nil
[159] Fix | Delete
while true
[160] Fix | Delete
redirect = catch(:open_uri_redirect) {
[161] Fix | Delete
buf = Buffer.new
[162] Fix | Delete
uri.buffer_open(buf, find_proxy.call(uri), options)
[163] Fix | Delete
nil
[164] Fix | Delete
}
[165] Fix | Delete
if redirect
[166] Fix | Delete
if redirect.relative?
[167] Fix | Delete
# Although it violates RFC2616, Location: field may have relative
[168] Fix | Delete
# URI. It is converted to absolute URI using uri as a base URI.
[169] Fix | Delete
redirect = uri + redirect
[170] Fix | Delete
end
[171] Fix | Delete
unless OpenURI.redirectable?(uri, redirect)
[172] Fix | Delete
raise "redirection forbidden: #{uri} -> #{redirect}"
[173] Fix | Delete
end
[174] Fix | Delete
if options.include? :http_basic_authentication
[175] Fix | Delete
# send authentication only for the URI directly specified.
[176] Fix | Delete
options = options.dup
[177] Fix | Delete
options.delete :http_basic_authentication
[178] Fix | Delete
end
[179] Fix | Delete
uri = redirect
[180] Fix | Delete
raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s
[181] Fix | Delete
uri_set[uri.to_s] = true
[182] Fix | Delete
else
[183] Fix | Delete
break
[184] Fix | Delete
end
[185] Fix | Delete
end
[186] Fix | Delete
io = buf.io
[187] Fix | Delete
io.base_uri = uri
[188] Fix | Delete
io
[189] Fix | Delete
end
[190] Fix | Delete
[191] Fix | Delete
def OpenURI.redirectable?(uri1, uri2) # :nodoc:
[192] Fix | Delete
# This test is intended to forbid a redirection from http://... to
[193] Fix | Delete
# file:///etc/passwd.
[194] Fix | Delete
# However this is ad hoc. It should be extensible/configurable.
[195] Fix | Delete
uri1.scheme.downcase == uri2.scheme.downcase ||
[196] Fix | Delete
(/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:http|ftp)\z/i =~ uri2.scheme)
[197] Fix | Delete
end
[198] Fix | Delete
[199] Fix | Delete
def OpenURI.open_http(buf, target, proxy, options) # :nodoc:
[200] Fix | Delete
if proxy
[201] Fix | Delete
raise "Non-HTTP proxy URI: #{proxy}" if proxy.class != URI::HTTP
[202] Fix | Delete
end
[203] Fix | Delete
[204] Fix | Delete
if target.userinfo && "1.9.0" <= RUBY_VERSION
[205] Fix | Delete
# don't raise for 1.8 because compatibility.
[206] Fix | Delete
raise ArgumentError, "userinfo not supported. [RFC3986]"
[207] Fix | Delete
end
[208] Fix | Delete
[209] Fix | Delete
require 'net/http'
[210] Fix | Delete
klass = Net::HTTP
[211] Fix | Delete
if URI::HTTP === target
[212] Fix | Delete
# HTTP or HTTPS
[213] Fix | Delete
if proxy
[214] Fix | Delete
klass = Net::HTTP::Proxy(proxy.host, proxy.port)
[215] Fix | Delete
end
[216] Fix | Delete
target_host = target.host
[217] Fix | Delete
target_port = target.port
[218] Fix | Delete
request_uri = target.request_uri
[219] Fix | Delete
else
[220] Fix | Delete
# FTP over HTTP proxy
[221] Fix | Delete
target_host = proxy.host
[222] Fix | Delete
target_port = proxy.port
[223] Fix | Delete
request_uri = target.to_s
[224] Fix | Delete
end
[225] Fix | Delete
[226] Fix | Delete
http = klass.new(target_host, target_port)
[227] Fix | Delete
if target.class == URI::HTTPS
[228] Fix | Delete
require 'net/https'
[229] Fix | Delete
http.use_ssl = true
[230] Fix | Delete
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
[231] Fix | Delete
store = OpenSSL::X509::Store.new
[232] Fix | Delete
store.set_default_paths
[233] Fix | Delete
http.cert_store = store
[234] Fix | Delete
end
[235] Fix | Delete
[236] Fix | Delete
header = {}
[237] Fix | Delete
options.each {|k, v| header[k] = v if String === k }
[238] Fix | Delete
[239] Fix | Delete
resp = nil
[240] Fix | Delete
http.start {
[241] Fix | Delete
req = Net::HTTP::Get.new(request_uri, header)
[242] Fix | Delete
if options.include? :http_basic_authentication
[243] Fix | Delete
user, pass = options[:http_basic_authentication]
[244] Fix | Delete
req.basic_auth user, pass
[245] Fix | Delete
end
[246] Fix | Delete
http.request(req) {|response|
[247] Fix | Delete
resp = response
[248] Fix | Delete
if options[:content_length_proc] && Net::HTTPSuccess === resp
[249] Fix | Delete
if resp.key?('Content-Length')
[250] Fix | Delete
options[:content_length_proc].call(resp['Content-Length'].to_i)
[251] Fix | Delete
else
[252] Fix | Delete
options[:content_length_proc].call(nil)
[253] Fix | Delete
end
[254] Fix | Delete
end
[255] Fix | Delete
resp.read_body {|str|
[256] Fix | Delete
buf << str
[257] Fix | Delete
if options[:progress_proc] && Net::HTTPSuccess === resp
[258] Fix | Delete
options[:progress_proc].call(buf.size)
[259] Fix | Delete
end
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
io = buf.io
[264] Fix | Delete
io.rewind
[265] Fix | Delete
io.status = [resp.code, resp.message]
[266] Fix | Delete
resp.each {|name,value| buf.io.meta_add_field name, value }
[267] Fix | Delete
case resp
[268] Fix | Delete
when Net::HTTPSuccess
[269] Fix | Delete
when Net::HTTPMovedPermanently, # 301
[270] Fix | Delete
Net::HTTPFound, # 302
[271] Fix | Delete
Net::HTTPSeeOther, # 303
[272] Fix | Delete
Net::HTTPTemporaryRedirect # 307
[273] Fix | Delete
throw :open_uri_redirect, URI.parse(resp['location'])
[274] Fix | Delete
else
[275] Fix | Delete
raise OpenURI::HTTPError.new(io.status.join(' '), io)
[276] Fix | Delete
end
[277] Fix | Delete
end
[278] Fix | Delete
[279] Fix | Delete
class HTTPError < StandardError
[280] Fix | Delete
def initialize(message, io)
[281] Fix | Delete
super(message)
[282] Fix | Delete
@io = io
[283] Fix | Delete
end
[284] Fix | Delete
attr_reader :io
[285] Fix | Delete
end
[286] Fix | Delete
[287] Fix | Delete
class Buffer # :nodoc:
[288] Fix | Delete
def initialize
[289] Fix | Delete
@io = StringIO.new
[290] Fix | Delete
@size = 0
[291] Fix | Delete
end
[292] Fix | Delete
attr_reader :size
[293] Fix | Delete
[294] Fix | Delete
StringMax = 10240
[295] Fix | Delete
def <<(str)
[296] Fix | Delete
@io << str
[297] Fix | Delete
@size += str.length
[298] Fix | Delete
if StringIO === @io && StringMax < @size
[299] Fix | Delete
require 'tempfile'
[300] Fix | Delete
io = Tempfile.new('open-uri')
[301] Fix | Delete
io.binmode
[302] Fix | Delete
Meta.init io, @io if @io.respond_to? :meta
[303] Fix | Delete
io << @io.string
[304] Fix | Delete
@io = io
[305] Fix | Delete
end
[306] Fix | Delete
end
[307] Fix | Delete
[308] Fix | Delete
def io
[309] Fix | Delete
Meta.init @io unless @io.respond_to? :meta
[310] Fix | Delete
@io
[311] Fix | Delete
end
[312] Fix | Delete
end
[313] Fix | Delete
[314] Fix | Delete
# Mixin for holding meta-information.
[315] Fix | Delete
module Meta
[316] Fix | Delete
def Meta.init(obj, src=nil) # :nodoc:
[317] Fix | Delete
obj.extend Meta
[318] Fix | Delete
obj.instance_eval {
[319] Fix | Delete
@base_uri = nil
[320] Fix | Delete
@meta = {}
[321] Fix | Delete
}
[322] Fix | Delete
if src
[323] Fix | Delete
obj.status = src.status
[324] Fix | Delete
obj.base_uri = src.base_uri
[325] Fix | Delete
src.meta.each {|name, value|
[326] Fix | Delete
obj.meta_add_field(name, value)
[327] Fix | Delete
}
[328] Fix | Delete
end
[329] Fix | Delete
end
[330] Fix | Delete
[331] Fix | Delete
# returns an Array which consists status code and message.
[332] Fix | Delete
attr_accessor :status
[333] Fix | Delete
[334] Fix | Delete
# returns a URI which is base of relative URIs in the data.
[335] Fix | Delete
# It may differ from the URI supplied by a user because redirection.
[336] Fix | Delete
attr_accessor :base_uri
[337] Fix | Delete
[338] Fix | Delete
# returns a Hash which represents header fields.
[339] Fix | Delete
# The Hash keys are downcased for canonicalization.
[340] Fix | Delete
attr_reader :meta
[341] Fix | Delete
[342] Fix | Delete
def meta_add_field(name, value) # :nodoc:
[343] Fix | Delete
@meta[name.downcase] = value
[344] Fix | Delete
end
[345] Fix | Delete
[346] Fix | Delete
# returns a Time which represents Last-Modified field.
[347] Fix | Delete
def last_modified
[348] Fix | Delete
if v = @meta['last-modified']
[349] Fix | Delete
Time.httpdate(v)
[350] Fix | Delete
else
[351] Fix | Delete
nil
[352] Fix | Delete
end
[353] Fix | Delete
end
[354] Fix | Delete
[355] Fix | Delete
RE_LWS = /[\r\n\t ]+/n
[356] Fix | Delete
RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n
[357] Fix | Delete
RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])*"}n
[358] Fix | Delete
RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n
[359] Fix | Delete
[360] Fix | Delete
def content_type_parse # :nodoc:
[361] Fix | Delete
v = @meta['content-type']
[362] Fix | Delete
# The last (?:;#{RE_LWS}?)? matches extra ";" which violates RFC2045.
[363] Fix | Delete
if v && %r{\A#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?/(#{RE_TOKEN})#{RE_LWS}?(#{RE_PARAMETERS})(?:;#{RE_LWS}?)?\z}no =~ v
[364] Fix | Delete
type = $1.downcase
[365] Fix | Delete
subtype = $2.downcase
[366] Fix | Delete
parameters = []
[367] Fix | Delete
$3.scan(/;#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?=#{RE_LWS}?(?:(#{RE_TOKEN})|(#{RE_QUOTED_STRING}))/no) {|att, val, qval|
[368] Fix | Delete
val = qval.gsub(/[\r\n\t !#-\[\]-~\x80-\xff]+|(\\[\x00-\x7f])/) { $1 ? $1[1,1] : $& } if qval
[369] Fix | Delete
parameters << [att.downcase, val]
[370] Fix | Delete
}
[371] Fix | Delete
["#{type}/#{subtype}", *parameters]
[372] Fix | Delete
else
[373] Fix | Delete
nil
[374] Fix | Delete
end
[375] Fix | Delete
end
[376] Fix | Delete
[377] Fix | Delete
# returns "type/subtype" which is MIME Content-Type.
[378] Fix | Delete
# It is downcased for canonicalization.
[379] Fix | Delete
# Content-Type parameters are stripped.
[380] Fix | Delete
def content_type
[381] Fix | Delete
type, *parameters = content_type_parse
[382] Fix | Delete
type || 'application/octet-stream'
[383] Fix | Delete
end
[384] Fix | Delete
[385] Fix | Delete
# returns a charset parameter in Content-Type field.
[386] Fix | Delete
# It is downcased for canonicalization.
[387] Fix | Delete
#
[388] Fix | Delete
# If charset parameter is not given but a block is given,
[389] Fix | Delete
# the block is called and its result is returned.
[390] Fix | Delete
# It can be used to guess charset.
[391] Fix | Delete
#
[392] Fix | Delete
# If charset parameter and block is not given,
[393] Fix | Delete
# nil is returned except text type in HTTP.
[394] Fix | Delete
# In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1.
[395] Fix | Delete
def charset
[396] Fix | Delete
type, *parameters = content_type_parse
[397] Fix | Delete
if pair = parameters.assoc('charset')
[398] Fix | Delete
pair.last.downcase
[399] Fix | Delete
elsif block_given?
[400] Fix | Delete
yield
[401] Fix | Delete
elsif type && %r{\Atext/} =~ type &&
[402] Fix | Delete
@base_uri && /\Ahttp\z/i =~ @base_uri.scheme
[403] Fix | Delete
"iso-8859-1" # RFC2616 3.7.1
[404] Fix | Delete
else
[405] Fix | Delete
nil
[406] Fix | Delete
end
[407] Fix | Delete
end
[408] Fix | Delete
[409] Fix | Delete
# returns a list of encodings in Content-Encoding field
[410] Fix | Delete
# as an Array of String.
[411] Fix | Delete
# The encodings are downcased for canonicalization.
[412] Fix | Delete
def content_encoding
[413] Fix | Delete
v = @meta['content-encoding']
[414] Fix | Delete
if v && %r{\A#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?(?:,#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?)*}o =~ v
[415] Fix | Delete
v.scan(RE_TOKEN).map {|content_coding| content_coding.downcase}
[416] Fix | Delete
else
[417] Fix | Delete
[]
[418] Fix | Delete
end
[419] Fix | Delete
end
[420] Fix | Delete
end
[421] Fix | Delete
[422] Fix | Delete
# Mixin for HTTP and FTP URIs.
[423] Fix | Delete
module OpenRead
[424] Fix | Delete
# OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP.
[425] Fix | Delete
#
[426] Fix | Delete
# OpenURI::OpenRead#open takes optional 3 arguments as:
[427] Fix | Delete
# OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }]
[428] Fix | Delete
#
[429] Fix | Delete
# `mode', `perm' is same as Kernel#open.
[430] Fix | Delete
#
[431] Fix | Delete
# However, `mode' must be read mode because OpenURI::OpenRead#open doesn't
[432] Fix | Delete
# support write mode (yet).
[433] Fix | Delete
# Also `perm' is just ignored because it is meaningful only for file
[434] Fix | Delete
# creation.
[435] Fix | Delete
#
[436] Fix | Delete
# `options' must be a hash.
[437] Fix | Delete
#
[438] Fix | Delete
# Each pairs which key is a string in the hash specify a extra header
[439] Fix | Delete
# field for HTTP.
[440] Fix | Delete
# I.e. it is ignored for FTP without HTTP proxy.
[441] Fix | Delete
#
[442] Fix | Delete
# The hash may include other options which key is a symbol:
[443] Fix | Delete
#
[444] Fix | Delete
# [:proxy]
[445] Fix | Delete
# Synopsis:
[446] Fix | Delete
# :proxy => "http://proxy.foo.com:8000/"
[447] Fix | Delete
# :proxy => URI.parse("http://proxy.foo.com:8000/")
[448] Fix | Delete
# :proxy => true
[449] Fix | Delete
# :proxy => false
[450] Fix | Delete
# :proxy => nil
[451] Fix | Delete
#
[452] Fix | Delete
# If :proxy option is specified, the value should be String, URI,
[453] Fix | Delete
# boolean or nil.
[454] Fix | Delete
# When String or URI is given, it is treated as proxy URI.
[455] Fix | Delete
# When true is given or the option itself is not specified,
[456] Fix | Delete
# environment variable `scheme_proxy' is examined.
[457] Fix | Delete
# `scheme' is replaced by `http', `https' or `ftp'.
[458] Fix | Delete
# When false or nil is given, the environment variables are ignored and
[459] Fix | Delete
# connection will be made to a server directly.
[460] Fix | Delete
#
[461] Fix | Delete
# [:http_basic_authentication]
[462] Fix | Delete
# Synopsis:
[463] Fix | Delete
# :http_basic_authentication=>[user, password]
[464] Fix | Delete
#
[465] Fix | Delete
# If :http_basic_authentication is specified,
[466] Fix | Delete
# the value should be an array which contains 2 strings:
[467] Fix | Delete
# username and password.
[468] Fix | Delete
# It is used for HTTP Basic authentication defined by RFC 2617.
[469] Fix | Delete
#
[470] Fix | Delete
# [:content_length_proc]
[471] Fix | Delete
# Synopsis:
[472] Fix | Delete
# :content_length_proc => lambda {|content_length| ... }
[473] Fix | Delete
#
[474] Fix | Delete
# If :content_length_proc option is specified, the option value procedure
[475] Fix | Delete
# is called before actual transfer is started.
[476] Fix | Delete
# It takes one argument which is expected content length in bytes.
[477] Fix | Delete
#
[478] Fix | Delete
# If two or more transfer is done by HTTP redirection, the procedure
[479] Fix | Delete
# is called only one for a last transfer.
[480] Fix | Delete
#
[481] Fix | Delete
# When expected content length is unknown, the procedure is called with
[482] Fix | Delete
# nil.
[483] Fix | Delete
# It is happen when HTTP response has no Content-Length header.
[484] Fix | Delete
#
[485] Fix | Delete
# [:progress_proc]
[486] Fix | Delete
# Synopsis:
[487] Fix | Delete
# :progress_proc => lambda {|size| ...}
[488] Fix | Delete
#
[489] Fix | Delete
# If :progress_proc option is specified, the proc is called with one
[490] Fix | Delete
# argument each time when `open' gets content fragment from network.
[491] Fix | Delete
# The argument `size' `size' is a accumulated transfered size in bytes.
[492] Fix | Delete
#
[493] Fix | Delete
# If two or more transfer is done by HTTP redirection, the procedure
[494] Fix | Delete
# is called only one for a last transfer.
[495] Fix | Delete
#
[496] Fix | Delete
# :progress_proc and :content_length_proc are intended to be used for
[497] Fix | Delete
# progress bar.
[498] Fix | Delete
# For example, it can be implemented as follows using Ruby/ProgressBar.
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function