Created
January 5, 2016 05:13
-
-
Save r6m/85e35f849389c8208645 to your computer and use it in GitHub Desktop.
https get with param using Net::HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'net/http' | |
require 'uri' | |
require 'cgi' | |
mode = 'prod' | |
id = '000000' | |
new = 'true' | |
uri_domain = 'https://www.example.com' | |
uri_path = | |
'/some/path/to/file.cfm' | |
params = | |
{:mode => mode, :id => id, :new => new} | |
uri_string = | |
uri_domain + | |
uri_path + | |
"?" + | |
params.map{|k,v| "#{k}=#{CGI::escape(v.to_s)}"}.join('&') | |
uri = URI(uri_string) | |
Net::HTTP.start(uri.host, | |
uri.port, | |
:use_ssl => uri.scheme == 'https', | |
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| | |
request = Net::HTTP::Get.new uri.request_uri | |
response = http.request request | |
puts response.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment