make a http connect request in ruby

Here's an example of how to make an HTTP connection request in Ruby using the Net::HTTP library:

main.rb
require 'net/http'

url = URI.parse('https://www.example.com')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
response = http.request(request)

puts response.body
212 chars
11 lines

In this example, we use Net::HTTP to create a new HTTP connection to www.example.com with SSL enabled. We then create a new Net::HTTP::Get request for the URL, and we send the request using the http.request(request) method. Finally, we output the response body using puts response.body. You can use this example as a starting point to create more complex HTTP requests and handle the responses accordingly.

gistlibby LogSnag