Allow `Net::HTTP.get`, `get_response`, `post`, `post_form`, `put` to receive URI `String`
We need to pass a URI object to Net::HTTP.get_response (or Net::HTTP.get).
Net::HTTP.get_response(URI('http://www.example.com/index.html'))
With this patch, these methods can receive a URI-string.
Net::HTTP.get_response('http://www.example.com/index.html')
IMO it's unreasonable and pointless to define a method with a UTF-16 name, see https://github.com/truffleruby/truffleruby/issues/4005#issuecomment-3450942799. I think CRuby should actually prevent defining such a method in a dummy (Encoding::UTF_16) or ASCII-incompatible encoding (Encoding::UTF_16LE/Encoding::UTF_16BE).
I think CRuby should actually prevent defining such a method in a dummy (Encoding::UTF_16) or ASCII-incompatible encoding (Encoding::UTF_16LE/Encoding::UTF_16BE).
What would you like to see? A particular exception thrown?
All 3 UTF-16 encodings are ASCII-incompatible:
irb(main):001> Encoding::UTF_16.ascii_compatible?
=> false
irb(main):002> Encoding::UTF_16LE.ascii_compatible?
=> false
irb(main):003> Encoding::UTF_16BE.ascii_compatible?
=> false
And Ruby only supports sources in ASCII-compatible encodings:
$ ruby -e '# encoding: utf-16le'
-e:1: UTF-16LE is not ASCII compatible (ArgumentError)
So I think either an ArgumentError or maybe Encoding::CompatibilityError when define_method receives a name in an ASCII-incompatible encoding.
For example filesystem operations reject such ASCII-incompatible encodings:
irb(main):004> File.read("abc".encode(Encoding::UTF_16LE))
(irb):4:in `read': path name must be ASCII-compatible (UTF-16LE): "abc" (Encoding::CompatibilityError)
from (irb):4:in `<main>'
from <internal:kernel>:187:in `loop'
from /home/eregon/.rubies/ruby-3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.13.1/exe/irb:9:in `<top (required)>'
from /home/eregon/.rubies/ruby-3.3.5/bin/irb:25:in `load'
from /home/eregon/.rubies/ruby-3.3.5/bin/irb:25:in `<main>'