aboutsummaryrefslogtreecommitdiffstats
path: root/lib/open-uri.rb
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/open-uri] Bump up 0.4.1Hiroshi SHIBATA2023-12-071-1/+1
| | | | https://github.com/ruby/open-uri/commit/d72508a7f4
* [ruby/open-uri] Set default for max_redirects and add exception classAndrew Kane2023-12-071-2/+5
| | | | https://github.com/ruby/open-uri/commit/dcdcb885cc
* [ruby/open-uri] Add :max_redirects optionAndrew Kane2023-12-071-0/+3
| | | | https://github.com/ruby/open-uri/commit/7fd5ea09a7
* [ruby/open-uri] Bump up 0.4.0Hiroshi SHIBATA2023-11-071-1/+1
| | | | https://github.com/ruby/open-uri/commit/09df813305
* [ruby/open-uri] Make URI.open pass keywordsJeremy Evans2023-08-231-0/+1
| | | | | | Fixes [Bug #19238] https://github.com/ruby/open-uri/commit/f636d01b85
* [ruby/open-uri] Expose OpenURI::VERSIONHiroshi SHIBATA2023-04-131-0/+3
| | | | https://github.com/ruby/open-uri/commit/666768d960
* Add :ssl_min_version and :ssl_max_version optionsKazuki Yamaguchi2022-10-121-3/+18
| | | | | | Replace :ssl_version option with these two new options. These provide access to OpenSSL::SSL::SSLContext#{min,max}_version=, which is the recommended way to specify SSL/TLS protocol versions.
* [ruby/open-uri] Support 308 status redirectJanko Marohnić2022-10-071-1/+2
| | | | https://github.com/ruby/open-uri/commit/d8899ae4ac
* * remove trailing spaces. [ci skip]git2022-10-061-1/+1
|
* [ruby/open-uri] feat: allow option to pass version of SSL / TLS to use ↵Nishant Patel2022-10-061-0/+3
| | | | | | during communication. Allow versions are OpenSSL::SSL::SSLContext::METHODS https://github.com/ruby/open-uri/commit/8729858517
* [ruby/open-uri] Avoid busting the global constant cacheJean Boussier2022-10-061-7/+7
| | | | | | | | | | `Object#extend(mod)` bump the global constant cache if the module has constants of its own. So by moving these constants outside of `Meta` we avoid bumping the cache. https://github.com/ruby/open-uri/commit/363c399bac
* [ruby/open-uri] [DOC] Fix markup for `URI.open`Alexander Ilyin2022-06-071-1/+1
| | | | | | * Add missing slash. https://github.com/ruby/open-uri/commit/40023e63da
* Guard for the ftp protocol feature of OpenURIHiroshi SHIBATA2021-05-271-1/+6
|
* Remove the deprecated override of Kernel#open in open-uriJeremy Evans2020-08-161-24/+1
| | | | This was deprecated in 2.7 to resolve [Misc #15893].
* [DOC] get rid of parsing as TIDYLINK unintentionallyNobuyoshi Nakada2020-04-071-1/+1
|
* Add `URI#open` to warning messageKazuhiro NISHIYAMA2019-12-201-1/+1
|
* open-uri: change global docs to reflect that URI.open syntax is preferredzverok2019-10-261-7/+7
|
* Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans2019-09-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function.
* The default charset of text/* media type is UTF-8.Tanaka Akira2019-07-151-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thanks for the patch gareth (Gareth Adams). [Bug #15933] ------- Combines two small, but very related changes 1: Treat HTTPS the same as HTTP Previously, OpenURI followed guidance in RFC2616/3.7.1: > When no explicit charset parameter is provided by the sender, media > subtypes of the "text" type are defined to have a default charset > value of "ISO-8859-1" when received via HTTP. However this RFC was written before TLS was established and OpenURI was never updated to treat HTTPS traffic the same way. So, HTTPS documents received a different default to HTTP documents. This commit removes the scheme check so that all text/* documents processed by OpenURI are treated the same way. In theory this processing gets applied to FTP URIs too, but there's no mechanism in OpenURI for FTP documents to have Content-Type metadata appended to them, so this ends up being a no-op. 2: Change default charset for text/* to UTF-8 Replaces the default ISO-8859-1 charset previously defined in RFC2616 (now obsoleted) with a UTF-8 charset as defined in RFC6838. Fixes: https://bugs.ruby-lang.org/issues/15933
* Warn open-uri's "open" method at Kernel.Tanaka Akira2019-07-141-9/+18
| | | | | | Use URI.open instead. Thanks for the patch by jeremyevans0 (Jeremy Evans) [Misc #15893].
* open-uri: clear string after bufferingnormal2018-01-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since r58846 (in Ruby 2.5), it is safe to clear the string yielded to Net::HTTPResponse#read_body methods. This reduces malloc garbage (anonymous RSS) using the Linux-only script below: before: user system total real 0.030000 0.250000 0.280000 ( 0.280511) RssAnon: 60240 kB after: user system total real 0.050000 0.223333 0.273333 ( 0.273118) RssAnon: 6676 kB ------ # warning this script requires 1G free space for buffering require 'open-uri' require 'socket' require 'benchmark' s = TCPServer.new('127.0.0.1', 0) len = 1024 * 1024 * 1024 buf = ((0..255).map(&:chr).join * 128) nr = len / buf.size pid = fork do c = s.accept c.readpartial(16384).clear c.write("HTTP/1.1 200 OK\r\n" \ "Content-Length: #{len}\r\n" \ "Content-Type: application/octet-stream\r\n" \ "\r\n") buf.freeze # speeds up IO#write slightly nr.times { c.write(buf) } c.close end addr = s.addr open("http://#{addr[3]}:#{addr[1]}/", "rb") do |fp| bm = Benchmark.measure do while fp.read(16384, buf) end end puts bm end puts File.readlines("/proc/#$$/status").grep(/RssAnon/)[0] Process.waitpid2(pid) ------ * lib/open-uri.rb: clear string yielded by Net::HTTPResponse#read_body [ruby-core:84662] [Feature #14320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* open-uri defines URI.open defined as an alias.akr2017-12-211-0/+7
| | | | | | | | open-uri's Kernel.open will be deprecated in future. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/open-uri.rb: accept :encoding option as well as encoding in mode string.akr2017-10-211-0/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Improved documentation grammar forhsbt2016-10-201-2/+2
| | | | | | open-uri#open option. [Misc #11329][ruby-core:69868][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/open-uri.rb: Allow http to https redirection.akr2016-09-071-1/+1
| | | | | | | | | | * lib/open-uri.rb: Allow http to https redirection. Note that https to http is still forbidden. [ruby-core:20485] [Feature #859] by Roman Shterenzon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Use `userinfo` for authenticated proxy.hsbt2016-03-301-0/+3
| | | | | | | | [fix GH-1148] Patch by @SokichiFujita * test/open-uri/test_open-uri.rb: ditto. [fix GH-1309] Patch by @jdamick git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* stdlib: avoid extra calls to eliminate "\n" from Base64normal2016-01-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | We may use the '0' (zero) to avoid adding the line feed. Furthermore, the '*' (asterisk) modifier is not needed for a single-element arrays. * ext/psych/lib/psych/visitors/yaml_tree.rb (visit_String): eliminate chomp * lib/net/http.rb (connect): eliminate delete * lib/net/http/header.rb (basic_encode): ditto * lib/net/imap.rb (authenticate): eliminate gsub (self.encode_utf7): shorten delete arg * lib/net/smtp.rb (base64_encode): eliminate gsub * lib/open-uri.rb (OpenURI.open_http): eliminate delete * lib/rss/rss.rb: ditto * lib/securerandom.rb (base64): ditto (urlsafe_base64): eliminate delete! * lib/webrick/httpauth/digestauth.rb (split_param_value): eliminate chop * lib/webrick/httpproxy.rb (do_CONNECT): eliminate delete (setup_upstream_proxy_authentication): ditto [ruby-core:72666] [Feature #11938] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/ftp.rb (initialize): Connections are in passive mode pershugo2015-11-111-1/+1
| | | | | | | | | default now. The default mode can be changed by Net::FTP.default_passive=. * lib/net/ftp.rb (default_passive=, default_passive): new methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Remove indicator for "frozen_string_literal: true".akr2015-11-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/pp.rb: Ditto. * lib/prettyprint.rb: Ditto. * lib/resolv.rb: Ditto. * lib/securerandom.rb: Ditto. * lib/tmpdir.rb: Ditto. * lib/unicode_normalize/tables.rb: Ditto. * test/net/ftp/test_buffered_socket.rb: Ditto. * test/net/ftp/test_mlsx_entry.rb: Ditto. * test/open-uri/test_open-uri.rb: Ditto. * test/open-uri/test_ssl.rb: Ditto. * test/pathname/test_pathname.rb: Ditto. * test/test_pp.rb: Ditto. * test/test_prettyprint.rb: Ditto. * tool/transcode-tblgen.rb: Ditto. * ext/pathname/lib/pathname.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Specify frozen_string_literal: true.akr2015-10-181-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb (OpenURI.open_http): refactoring of r48941.usa2014-12-241-2/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb (OpenURI.open_http): accept multiple certs path inusa2014-12-231-5/+8
| | | | | | | | | ssl_ca_certs. * tool/downloader.rb: use certs of rubygems for downloading gems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* open-uri: accept :open_timeout optionnormal2014-10-101-0/+11
| | | | | | | | | | * lib/open-uri.rb (OpenURI::Options): add :open_timeout default * (def OpenURI.open_http): check :open_timeout option * (module OpenURI): rdoc for :open_timeout * test/open-uri/test_open-uri.rb (test_open_timeout): new test [Feature #10361] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: remove needless condition for old ruby version.hsbt2014-08-081-2/+1
| | | | | | * test/open-uri/test_open-uri.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb (OpenURI.open_uri): Call StringIO#close only ifakr2014-05-051-1/+1
| | | | | | | | the StringIO object is not closed yet. Reported by Jordi Massaguer Pla. [ruby-core:42538] [Bug #6010] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: [DOC] use lower case version of core classes, samezzak2014-02-071-2/+3
| | | | | | | as commit r44878, based on patch by Jonathan Jackson [Bug #9483] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Make proxy disabling working again.akr2014-01-181-1/+1
| | | | | | | Fixed by Christophe Philemotte. [ruby-core:59650] [Bug #9385] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/smtp.rb: [DOC] Remove dead link to RAA by Giorgos Tsiftsiszzak2014-01-131-1/+1
| | | | | | | | Fixes the following bugs: [Bug #9152] [Bug #9268] [Bug #9394] * lib/open-uri.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb (meta_add_field): : Re-implemented.akr2013-10-261-0/+4
| | | | | | | | [ruby-core:58017] [Bug #9051] patch by Eamonn Webster. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Support multiple fields with same fieldakr2013-04-091-11/+22
| | | | | | | | | | | name (like Set-Cookie). (OpenURI::Meta#metas): New accessor to obtain fields as a Hash from field name (string) to field values (array of strings). [ruby-core:37734] [Bug #4964] reported by ren li. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Documentation for OpenURIzzak2012-10-201-8/+15
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: use respond_to? to test Tempfile.akr2012-07-231-2/+2
| | | | | | | | [ruby-dev:45995] [Bug #6781] reported by hsbt (Hiroshi SHIBATA). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http.rb: Net::HTTP now automatically detects and usesdrbrain2012-07-201-78/+0
| | | | | | | | | | | | | | | | | | | | | | proxies from the environment. A proxy may also be specified as before. Net::HTTP::Proxy still creates anonymous classes, but these classes are only used to store configuration information. When an HTTP instance is created the configuration is now copied. Additionally, Net::HTTP::ProxyDelta is no longer used by Net::HTTP [Feature #6546] * lib/open-uri.rb: Moved URI::Generic#find_proxy to uri/generic. * lib/uri/generic.rb: Imported find_proxy from open-uri. * test/open-uri/test_open-uri.rb: Moved proxy-discovery tests to URI. * test/uri/test_generic.rb: Imported proxy-discovery tests from open-uri. * test/net/http/test_http.rb: Added tests for proxy behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: delete space.ayumin2012-07-171-1/+1
| | | | | | * test/psych/test_alias_and_anchor.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: call io.close! for Tempfile.akr2012-07-171-1/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Fix indentation of OpenURI::OpenRead#open. Use ++drbrain2011-08-261-27/+35
| | | | | | | instead of `' for method arguments in open-uri.rb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/pathname/lib/pathname.rb: Fix typos and grammar mistakes. Patchdrbrain2011-08-261-29/+27
| | | | | | | | | | | | | | | | by Luke Gruber. [#5203] * ext/pty/lib/expect.rb: ditto * lib/mathn.rb: ditto * lib/net/http.rb: ditto * lib/open-uri.rb: ditto * lib/ostruct.rb: ditto * lib/tempfile.rb: ditto * lib/thread.rb: ditto * lib/weakref.rb: ditto * sample/webrick/httpproxy.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* update comment.akr2011-05-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/resolv-replace.rb: suppress warning.akr2010-10-291-3/+3
| | | | | | | | * lib/open-uri.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/uri/generic.rb (URI::Generic#hostname): new method.akr2010-10-061-7/+7
| | | | | | | | | | | | | | (URI::Generic#hostname=): ditto. * lib/open-uri.rb: use URI#hostname * lib/net/http.rb: ditto. [ruby-core:32056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e