lib/ronin/web.rb in ronin-web-1.0.0 vs lib/ronin/web.rb in ronin-web-1.0.1
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
#
# ronin-web - A collection of useful web helper methods and commands.
#
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
#
@@ -32,10 +33,13 @@
require 'nokogiri/ext'
require 'nokogiri/diff'
require 'open_namespace'
module Ronin
+ #
+ # Top-level web helper methods.
+ #
module Web
include OpenNamespace
#
# Parses the body of a document into a HTML document object.
@@ -198,10 +202,11 @@
def self.open(url, proxy: Support::Network::HTTP.proxy,
user_agent: Support::Network::HTTP.user_agent,
referer: nil,
cookie: nil,
**kwargs)
+ uri = URI(url)
options = {proxy: proxy, **kwargs}
if user_agent
options['User-Agent'] = case user_agent
when Symbol
@@ -212,11 +217,11 @@
end
options['Referer'] = referer if referer
options['Cookie'] = cookie if cookie
- return URI.open(url,options)
+ return uri.open(options)
end
#
# A persistent Mechanize Agent.
#
@@ -342,10 +347,10 @@
# @see http://rubydoc.info/gems/mechanize/Mechanize/Page
#
# @api public
#
def self.post(url,query={},headers={},&block)
- agent.post(url,query,headers={},&block)
+ agent.post(url,query,headers,&block)
end
#
# Posts to a given URL and returns the body of the Mechanize Page
# created from the response.