#
#--
# Ronin - A Ruby platform designed for information security and data
# exploration tasks.
#
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#++
#
require 'ronin/network/http'
require 'ronin/extensions/uri/http'
require 'net/http'
module Net
#
# Connects to the HTTP server using the given _options_. If a _block_
# is given it will be passed the newly created Net::HTTP object.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
#
def Net.http_session(options={},&block)
options = Ronin::Network::HTTP.expand_options(options)
host = options[:host]
port = options[:port]
proxy = options[:proxy]
sess = Net::HTTP::Proxy(proxy[:host],proxy[:port],proxy[:user],proxy[:pass]).start(host,port)
if block
if block.arity == 2
block.call(sess,options)
else
block.call(sess)
end
end
return sess
end
#
# Connects to the HTTP server and sends an HTTP Request using the given
# _options_. If a _block_ is given it will be passed the newly created
# HTTP Request object. Returns the Net::HTTP::Response that
# was returned.
#
# _options_ may contain the following keys:
# :method:: The HTTP method to use for the request.
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the request.
# May use Strings or Symbols for the keys of the Hash.
#
def Net.http_request(options={},&block)
resp = nil
Net.http_session(options) do |http,expanded_options|
http_body = expanded_options.delete(:body)
req = Ronin::Network::HTTP.request(expanded_options)
if block
if block.arity == 2
block.call(req,expanded_options)
else
block.call(req)
end
end
resp = http.request(req,http_body)
end
return resp
end
#
# Performes an HTTP Copy request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Copy request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_copy(options={},&block)
resp = Net.http_request(options.merge(:method => :copy))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Delete request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Delete request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_delete(options={},&block)
original_headers = options[:headers]
# set the HTTP Depth header
options[:headers] = {:depth => 'Infinity'}
if original_headers
options[:header].merge!(original_headers)
end
resp = Net.http_request(options.merge(:method => :delete))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Get request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Get request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_get(options={},&block)
resp = Net.http_request(options.merge(:method => :get))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Get request with the given _options_. If a _block_
# is given, it will be passed the response body from the HTTP server.
# Returns the response body from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Get request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_get_body(options={},&block)
Net.http_get(options,&block).body
end
#
# Performes an HTTP Head request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Head request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_head(options={},&block)
resp = Net.http_request(options.merge(:method => :head))
block.call(resp) if block
return resp
end
#
# Returns +true+ if a HTTP Head request with the given _options_ returns
# the HTTP status code of 200, returns +false+ otherwise.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Head request. May use Strings or Symbols for the
# keys of the Hash.
#
#
def Net.http_ok?(options={})
Net.http_head(options).code == 200
end
#
# Sends a HTTP Head request using the given _options_ and returns the
# HTTP Server header.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Head request. May use Strings or Symbols for the
# keys of the Hash.
#
# Net.http_server(:url => 'http://www.darkc0de.com/)
# # => "Apache/2.2.11 (Unix) PHP/4.4.9 mod_ssl/2.2.11 OpenSSL/0.9.8c
# mod_fastcgi/2.4.6 Phusion_Passenger/2.1.2 DAV/2 SVN/1.4.2"
#
def Net.http_server(options={})
Net.http_head(options)['server']
end
#
# Sends an HTTP Head request using the given _options_ and returns the
# HTTP X-Powered-By header.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Head request. May use Strings or Symbols for the
# keys of the Hash.
#
# Net.http_powered_by(:url => 'http://www.stalkdaily.com/')
# # => "PHP/5.2.9"
#
def Net.http_powered_by(options={})
resp = Net.http_head(options)
if resp.code != 200
resp = Net.http_get(options)
end
return resp['x-powered-by']
end
#
# Performes an HTTP Lock request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Lock request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_lock(options={},&block)
resp = Net.http_request(options.merge(:method => :lock))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Mkcol request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Mkcol request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_mkcol(options={},&block)
resp = Net.http_request(options.merge(:method => :mkcol))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Move request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Move request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_move(options={},&block)
resp = Net.http_request(options.merge(:method => :move))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Options request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Options request. May use Strings or Symbols for
# the keys of the Hash.
#
def Net.http_options(options={},&block)
resp = Net.http_request(options.merge(:method => :options))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Post request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :post_data:: The POSTDATA to send with the HTTP Post request.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Post request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_post(options={},&block)
options = options.merge(:method => :post)
post_data = options.delete(:post_data)
if options[:url]
url = URI(options[:url].to_s)
post_data ||= url.query_params
end
resp = Net.http_request(options) do |req,expanded_options|
req.set_form_data(post_data) if post_data
end
block.call(resp) if block
return resp
end
#
# Performes an HTTP Post request with the given _options_. If a _block_
# is given, it will be passed the response body from the HTTP server.
# Returns the response body from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Post request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_post_body(options={},&block)
Net.http_post(options,&block).body
end
#
# Performes an HTTP Propfind request with the given _options_. If a
# _block_ is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Propfind request. May use Strings or Symbols for
# the keys of the Hash.
#
def Net.http_prop_find(options={},&block)
original_headers = options[:headers]
# set the HTTP Depth header
options[:headers] = {:depth => '0'}
if original_headers
options[:header].merge!(original_headers)
end
resp = Net.http_request(options.merge(:method => :propfind))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Proppatch request with the given _options_. If a
# _block_ is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Proppatch request. May use Strings or Symbols for
# the keys of the Hash.
#
def Net.http_prop_patch(options={},&block)
resp = Net.http_request(options.merge(:method => :proppatch))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Trace request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Trace request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_trace(options={},&block)
resp = Net.http_request(options.merge(:method => :trace))
block.call(resp) if block
return resp
end
#
# Performes an HTTP Unlock request with the given _options_. If a _block_
# is given, it will be passed the response from the HTTP server.
# Returns the response from the HTTP server.
#
# _options_ may contain the following keys:
# :url:: The full URL to request.
# :user:: The user to authenticate with when connecting to the
# HTTP server.
# :password:: The password to authenticate with when connecting
# to the HTTP server.
# :host:: The host the HTTP server is running on.
# :port:: The port the HTTP server is running on. Defaults to
# Net::HTTP.default_port.
# :path:: The path to request from the HTTP server.
# :proxy:: A Hash of proxy settings to use when connecting to
# the HTTP server. Defaults to
# Ronin::Network::HTTP.proxy.
# :host:: The HTTP proxy host to connect to.
# :port:: The HTTP proxy port to connect to.
# Defaults to Ronin::Network::HTTP.default_proxy_port.
# :user:: The user to authenticate with
# when connecting to the HTTP proxy.
# :password:: The password to authenticate with
# when connecting to the HTTP
# proxy.
# :headers:: A Hash of the HTTP Headers to send with the HTTP
# Unlock request. May use Strings or Symbols for the
# keys of the Hash.
#
def Net.http_unlock(options={},&block)
resp = Net.http_request(options.merge(:method => :unlock))
block.call(resp) if block
return resp
end
end