Skip to content

Changing URI.scheme does not affect imminent Net::HTTP.get #194

@forthrin

Description

@forthrin
require 'uri'
require 'net/http'

url = 'https://example.com/'
uri = URI(url)
uri.host = 'coffeescript.org' # change host
puts Net::HTTP.get(uri)[0, 256]
# Returns coffeescript page

url = 'http://coffeescript.org/'
uri = URI(url)
uri.scheme = 'https' # change scheme
puts Net::HTTP.get(uri)
# OpenSSL::SSL::SSLSocket#connect_nonblock': SSL_connect returned=1 errno=0 peeraddr=... state=error: record layer failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions