Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions