ronin 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data.tar.gz.sig +2 -0
  2. data/History.txt +43 -0
  3. data/Manifest.txt +27 -10
  4. data/README.txt +2 -1
  5. data/Rakefile +12 -11
  6. data/TODO.txt +8 -0
  7. data/bin/{ronin-ls → ronin-list} +2 -2
  8. data/bin/{ronin-rm → ronin-remove} +2 -2
  9. data/lib/ronin/cacheable.rb +25 -4
  10. data/lib/ronin/code/reference.rb +0 -9
  11. data/lib/ronin/code/symbol_table.rb +5 -5
  12. data/lib/ronin/code/token.rb +1 -1
  13. data/lib/ronin/database/database.rb +3 -1
  14. data/lib/ronin/extensions/kernel.rb +25 -3
  15. data/lib/ronin/formatting/extensions/binary/file.rb +60 -0
  16. data/lib/ronin/formatting/extensions/text.rb +1 -0
  17. data/lib/ronin/formatting/extensions/text/array.rb +67 -0
  18. data/lib/ronin/model.rb +1 -40
  19. data/lib/ronin/{has_license.rb → model/has_description.rb} +16 -18
  20. data/lib/ronin/model/has_license.rb +53 -0
  21. data/lib/ronin/model/has_name.rb +49 -0
  22. data/lib/ronin/model/has_version.rb +46 -0
  23. data/lib/ronin/model/model.rb +64 -0
  24. data/lib/ronin/network/extensions/http/net.rb +580 -99
  25. data/lib/ronin/network/http.rb +54 -6
  26. data/lib/ronin/os.rb +7 -7
  27. data/lib/ronin/platform/extension.rb +4 -6
  28. data/lib/ronin/platform/maintainer.rb +1 -1
  29. data/lib/ronin/platform/object_cache.rb +10 -2
  30. data/lib/ronin/platform/overlay_cache.rb +1 -1
  31. data/lib/ronin/platform/platform.rb +5 -3
  32. data/lib/ronin/platform/ronin.rb +3 -3
  33. data/lib/ronin/scanners.rb +25 -0
  34. data/lib/ronin/scanners/exceptions.rb +24 -0
  35. data/lib/ronin/scanners/exceptions/unknown_category.rb +29 -0
  36. data/lib/ronin/scanners/scanner.rb +239 -0
  37. data/lib/ronin/sessions/http.rb +548 -7
  38. data/lib/ronin/{translators.rb → templates.rb} +1 -1
  39. data/lib/ronin/templates/erb.rb +56 -0
  40. data/lib/ronin/ui/command_line/command_line.rb +10 -1
  41. data/lib/ronin/ui/command_line/commands/{ls.rb → list.rb} +1 -1
  42. data/lib/ronin/ui/command_line/commands/{rm.rb → remove.rb} +1 -1
  43. data/lib/ronin/ui/command_line/commands/uninstall.rb +2 -2
  44. data/lib/ronin/ui/console.rb +66 -17
  45. data/lib/ronin/ui/shell.rb +16 -36
  46. data/lib/ronin/version.rb +1 -1
  47. data/spec/cacheable_spec.rb +1 -1
  48. data/spec/code/classes/thing.rb +4 -0
  49. data/spec/code/reference_spec.rb +4 -0
  50. data/spec/code/symbol_table_spec.rb +5 -1
  51. data/spec/extensions/kernel_spec.rb +45 -5
  52. data/spec/extensions/string_spec.rb +4 -0
  53. data/spec/formatting/binary/integer_spec.rb +3 -3
  54. data/spec/formatting/binary/string_spec.rb +5 -5
  55. data/spec/formatting/digest/string_spec.rb +5 -9
  56. data/spec/formatting/http/string_spec.rb +5 -9
  57. data/spec/formatting/text/array_spec.rb +64 -0
  58. data/spec/formatting/text/string_spec.rb +3 -3
  59. data/spec/model/classes/licensed_model.rb +12 -0
  60. data/spec/{has_license_spec.rb → model/has_license_spec.rb} +5 -5
  61. data/spec/network/http_spec.rb +197 -0
  62. data/spec/os_spec.rb +2 -5
  63. data/spec/platform/maintainer_spec.rb +30 -0
  64. data/spec/platform/ronin_spec.rb +2 -2
  65. data/spec/scanners/classes/another_scanner.rb +16 -0
  66. data/spec/scanners/classes/example_scanner.rb +22 -0
  67. data/spec/scanners/scanner_spec.rb +148 -0
  68. data/spec/spec_helper.rb +1 -1
  69. data/spec/templates/classes/uses_erb.rb +11 -0
  70. data/spec/templates/erb_spec.rb +20 -0
  71. data/static/ronin/platform/overlay.xsl +128 -49
  72. metadata +83 -30
  73. metadata.gz.sig +0 -0
  74. data/lib/ronin/translators/translator.rb +0 -75
  75. data/spec/classes/licensed_model.rb +0 -12
  76. data/spec/translators/translator_spec.rb +0 -61
@@ -0,0 +1,60 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/formatting/extensions/binary/string'
25
+
26
+ class File
27
+
28
+ #
29
+ # Converts the hexdump at the specified _path_ back into the original
30
+ # raw-data using the given _options_.
31
+ #
32
+ # _options_ may contain the following keys:
33
+ # <tt>:format</tt>:: The expected format of the hexdump. Must be either
34
+ # <tt>:od</tt> or <tt>:hexdump</tt>.
35
+ # <tt>:encoding</tt>:: Denotes the encoding used for the bytes within the
36
+ # hexdump. Must be one of the following:
37
+ # <tt>:binary</tt>:: Binary encoded bytes.
38
+ # <tt>:octal</tt>:: Octal encoding.
39
+ # <tt>:octal_bytes</tt>:: Octal encoded bytes.
40
+ # <tt>:octal_shorts</tt>:: Octal encoded shorts.
41
+ # <tt>:octal_ints</tt>:: Octal encoded integers.
42
+ # <tt>:octal_quads</tt>:: Octal encoded quads.
43
+ # <tt>:decimal</tt>:: Unsigned decimal encoding.
44
+ # <tt>:decimal_bytes</tt>:: Unsigned decimal bytes.
45
+ # <tt>:decimal_shorts</tt>:: Unsigned decimal shorts.
46
+ # <tt>:decimal_ints</tt>:: Unsigned decimal ints.
47
+ # <tt>:decimal_quads</tt>:: Unsigned decimal quads.
48
+ # <tt>:hex</tt>:: Hexadecimal encoding.
49
+ # <tt>:hex_bytes</tt>:: Hexadecimal bytes.
50
+ # <tt>:hex_shorts</tt>:: Hexadecimal shorts.
51
+ # <tt>:hex_ints</tt>:: Hexadecimal ints.
52
+ # <tt>:hex_quads</tt>:: Hexadecimal quads.
53
+ # <tt>:segment</tt>:: The length in bytes of each segment in the hexdump.
54
+ # Defaults to 16, if not specified.
55
+ #
56
+ def File.unhexdump(path,options={})
57
+ File.read(path).unhexdump(options)
58
+ end
59
+
60
+ end
@@ -22,3 +22,4 @@
22
22
  #
23
23
 
24
24
  require 'ronin/formatting/extensions/text/string'
25
+ require 'ronin/formatting/extensions/text/array'
@@ -0,0 +1,67 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ class Array
25
+
26
+ #
27
+ # Returns the bytes contained in the array.
28
+ #
29
+ # [0x41, 0x41, 0x20].bytes
30
+ # # => [0x41, 0x41, 0x20]
31
+ #
32
+ # ['A', 'BB', 0x90].bytes
33
+ # # => [0x41, 0x42, 0x42, 0x90]
34
+ #
35
+ def bytes
36
+ self.inject([]) do |accum,elem|
37
+ if elem.kind_of?(Integer)
38
+ accum << elem
39
+ else
40
+ elem.to_s.each_byte { |b| accum << b }
41
+ end
42
+
43
+ accum
44
+ end
45
+ end
46
+
47
+ #
48
+ # Returns the Array of characters generated from the array.
49
+ #
50
+ # [0x41, 0x41, 0x20].chars
51
+ # # => ["A", "A", " "]
52
+ #
53
+ def chars
54
+ self.bytes.map { |b| b.chr }
55
+ end
56
+
57
+ #
58
+ # Returns the String created from the characters within the array.
59
+ #
60
+ # [0x41, 0x41, 0x20].char_string
61
+ # # => "AA "
62
+ #
63
+ def char_string
64
+ chars.join
65
+ end
66
+
67
+ end
data/lib/ronin/model.rb CHANGED
@@ -21,43 +21,4 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'dm-core'
25
- require 'dm-types'
26
- require 'dm-serializer'
27
- require 'dm-validations'
28
-
29
- module Ronin
30
- module Model
31
- include DataMapper::Types
32
-
33
- # Name of Ronin's DataMapper repository
34
- REPOSITORY_NAME = :ronin
35
-
36
- def self.included(base)
37
- unless base.ancestors.include?(DataMapper::Resource)
38
- base.module_eval do
39
- include DataMapper::Resource
40
- include DataMapper::AutoMigrations
41
-
42
- #
43
- # Returns the default repository name for the model.
44
- #
45
- def self.default_repository_name
46
- Model::REPOSITORY_NAME
47
- end
48
-
49
- # The class type property
50
- property :type, Discriminator
51
-
52
- #
53
- # Finds the first resource by conditions, or initializes a new
54
- # resource with the attributes if none found.
55
- #
56
- def self.first_or_new(query,attributes={})
57
- first(query) || new(query.merge(attributes))
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
24
+ require 'ronin/model/model'
@@ -22,28 +22,26 @@
22
22
  #
23
23
 
24
24
  require 'ronin/model'
25
- require 'ronin/license'
26
25
 
27
26
  module Ronin
28
- module HasLicense
29
- def self.included(base)
30
- base.module_eval do
31
- include Ronin::Model
27
+ module Model
28
+ module HasDescription
29
+ include DataMapper::Types
32
30
 
33
- # The license
34
- belongs_to :license,
35
- :child_key => [:license_id],
36
- :class_name => 'Ronin::License'
31
+ def self.included(base)
32
+ base.module_eval do
33
+ include Ronin::Model
37
34
 
38
- #
39
- # Returns all models having the predefined license with the
40
- # predefined _name_.
41
- #
42
- # LicensedModel.licensed_under(:cc_by_nc)
43
- # # => [#<Ronin::LicensedModel: ...>, ...]
44
- #
45
- def self.licensed_under(name)
46
- self.all(:license_id => Ronin::License[name].id)
35
+ # The description of the model
36
+ property :description, Text
37
+
38
+ #
39
+ # Finds models with descriptions similar to the specified
40
+ # _description_.
41
+ #
42
+ def self.describing(description)
43
+ self.all(:description.like => "%#{description}%")
44
+ end
47
45
  end
48
46
  end
49
47
  end
@@ -0,0 +1,53 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/model'
25
+ require 'ronin/license'
26
+
27
+ module Ronin
28
+ module Model
29
+ module HasLicense
30
+ def self.included(base)
31
+ base.module_eval do
32
+ include Ronin::Model
33
+
34
+ # The license
35
+ belongs_to :license,
36
+ :child_key => [:license_id],
37
+ :class_name => 'Ronin::License'
38
+
39
+ #
40
+ # Returns all models having the predefined license with the
41
+ # predefined _name_.
42
+ #
43
+ # LicensedModel.licensed_under(:cc_by_nc)
44
+ # # => [#<Ronin::LicensedModel: ...>, ...]
45
+ #
46
+ def self.licensed_under(name)
47
+ self.all(:license_id => Ronin::License[name].id)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/model'
25
+
26
+ module Ronin
27
+ module Model
28
+ module HasName
29
+ def self.included(base)
30
+ base.module_eval do
31
+ include Ronin::Model
32
+
33
+ # The name of the model
34
+ property :name, String, :index => true
35
+
36
+ # Validations
37
+ validates_present :name
38
+
39
+ #
40
+ # Finds models with names like the specified _name_.
41
+ #
42
+ def self.named(name)
43
+ self.all(:name.like => "%#{name}%")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/model'
25
+
26
+ module Ronin
27
+ module Model
28
+ module HasVersion
29
+ def self.included(base)
30
+ base.module_eval do
31
+ include Ronin::Model
32
+
33
+ # The version of the model
34
+ property :version, String, :default => '0.1', :index => true
35
+
36
+ #
37
+ # Finds latest version of the model.
38
+ #
39
+ def self.latest
40
+ self.first(:order => [:version.desc])
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,64 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ gem 'addressable', '2.0.2'
25
+
26
+ require 'dm-core'
27
+ require 'dm-types'
28
+ require 'dm-validations'
29
+
30
+ module Ronin
31
+ module Model
32
+ include DataMapper::Types
33
+
34
+ # Name of Ronin's DataMapper repository
35
+ REPOSITORY_NAME = :ronin
36
+
37
+ def self.included(base)
38
+ unless base.ancestors.include?(DataMapper::Resource)
39
+ base.module_eval do
40
+ include DataMapper::Resource
41
+ include DataMapper::AutoMigrations
42
+
43
+ #
44
+ # Returns the default repository name for the model.
45
+ #
46
+ def self.default_repository_name
47
+ Model::REPOSITORY_NAME
48
+ end
49
+
50
+ # The class type property
51
+ property :type, Discriminator
52
+
53
+ #
54
+ # Finds the first resource by conditions, or initializes a new
55
+ # resource with the attributes if none found.
56
+ #
57
+ def self.first_or_new(query,attributes={})
58
+ first(query) || new(query.merge(attributes))
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -32,14 +32,14 @@ module Net
32
32
  # is given it will be passed the newly created <tt>Net::HTTP</tt> object.
33
33
  #
34
34
  # _options_ may contain the following keys:
35
- # <tt>:host</tt>:: The host the HTTP server is running on.
36
- # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
37
- # <tt>Net::HTTP.default_port</tt>.
38
35
  # <tt>:url</tt>:: The full URL to request.
39
36
  # <tt>:user</tt>:: The user to authenticate with when connecting to the
40
37
  # HTTP server.
41
38
  # <tt>:password</tt>:: The password to authenticate with when connecting
42
39
  # to the HTTP server.
40
+ # <tt>:host</tt>:: The host the HTTP server is running on.
41
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
42
+ # <tt>Net::HTTP.default_port</tt>.
43
43
  # <tt>:path</tt>:: The path to request from the HTTP server.
44
44
  # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
45
45
  # the HTTP server. Defaults to
@@ -53,40 +53,77 @@ module Net
53
53
  # when connecting to the HTTP
54
54
  # proxy.
55
55
  #
56
- #
57
56
  def Net.http_session(options={},&block)
58
- host = options[:host]
59
- port = (options[:port] || ::Net::HTTP.default_port)
57
+ options = Ronin::Network::HTTP.expand_options(options)
60
58
 
61
- if options[:url]
62
- url = URI(options[:url].to_s)
63
-
64
- host = url.host
65
- port = url.port
59
+ host = options[:host]
60
+ port = options[:port]
61
+ proxy = options[:proxy]
66
62
 
67
- options[:user] = url.user if url.user
68
- options[:password] = url.password if url.password
63
+ sess = Net::HTTP::Proxy(proxy[:host],proxy[:port],proxy[:user],proxy[:pass]).start(host,port)
69
64
 
70
- if url.query
71
- options[:path] = "#{url.path}?#{url.query}"
65
+ if block
66
+ if block.arity == 2
67
+ block.call(sess,options)
72
68
  else
73
- options[:path] = url.path
69
+ block.call(sess)
74
70
  end
75
71
  end
76
72
 
77
- proxy = (options[:proxy] || Ronin::Network::HTTP.proxy)
73
+ return sess
74
+ end
78
75
 
79
- if proxy
80
- proxy_host = proxy[:host]
81
- proxy_port = (proxy[:port] || Ronin::Network::HTTP.default_proxy_port)
82
- proxy_user = proxy[:user]
83
- proxy_pass = proxy[:password]
84
- end
76
+ #
77
+ # Connects to the HTTP server and sends an HTTP Request using the given
78
+ # _options_. If a _block_ is given it will be passed the newly created
79
+ # HTTP Request object. Returns the <tt>Net::HTTP::Response</tt> that
80
+ # was returned.
81
+ #
82
+ # _options_ may contain the following keys:
83
+ # <tt>:method</tt>:: The HTTP method to use for the request.
84
+ # <tt>:url</tt>:: The full URL to request.
85
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
86
+ # HTTP server.
87
+ # <tt>:password</tt>:: The password to authenticate with when connecting
88
+ # to the HTTP server.
89
+ # <tt>:host</tt>:: The host the HTTP server is running on.
90
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
91
+ # <tt>Net::HTTP.default_port</tt>.
92
+ # <tt>:path</tt>:: The path to request from the HTTP server.
93
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
94
+ # the HTTP server. Defaults to
95
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
96
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
97
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
98
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
99
+ # <tt>:user</tt>:: The user to authenticate with
100
+ # when connecting to the HTTP proxy.
101
+ # <tt>:password</tt>:: The password to authenticate with
102
+ # when connecting to the HTTP
103
+ # proxy.
104
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the request.
105
+ # May use Strings or Symbols for the keys of the Hash.
106
+ #
107
+ def Net.http_request(options={},&block)
108
+ resp = nil
85
109
 
86
- sess = Net::HTTP::Proxy(proxy_host,proxy_port,proxy_user,proxy_pass).start(host,port)
110
+ Net.http_session(options) do |http,expanded_options|
111
+ http_body = expanded_options.delete(:body)
87
112
 
88
- block.call(sess) if block
89
- return sess
113
+ req = Ronin::Network::HTTP.request(expanded_options)
114
+
115
+ if block
116
+ if block.arity == 2
117
+ block.call(req,expanded_options)
118
+ else
119
+ block.call(req)
120
+ end
121
+ end
122
+
123
+ resp = http.request(req,http_body)
124
+ end
125
+
126
+ return resp
90
127
  end
91
128
 
92
129
  #
@@ -94,13 +131,36 @@ module Net
94
131
  # is given, it will be passed the response from the HTTP server.
95
132
  # Returns the response from the HTTP server.
96
133
  #
134
+ # _options_ may contain the following keys:
135
+ # <tt>:url</tt>:: The full URL to request.
136
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
137
+ # HTTP server.
138
+ # <tt>:password</tt>:: The password to authenticate with when connecting
139
+ # to the HTTP server.
140
+ # <tt>:host</tt>:: The host the HTTP server is running on.
141
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
142
+ # <tt>Net::HTTP.default_port</tt>.
143
+ # <tt>:path</tt>:: The path to request from the HTTP server.
144
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
145
+ # the HTTP server. Defaults to
146
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
147
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
148
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
149
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
150
+ # <tt>:user</tt>:: The user to authenticate with
151
+ # when connecting to the HTTP proxy.
152
+ # <tt>:password</tt>:: The password to authenticate with
153
+ # when connecting to the HTTP
154
+ # proxy.
155
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
156
+ # Copy request. May use Strings or Symbols for the
157
+ # keys of the Hash.
158
+ #
97
159
  def Net.http_copy(options={},&block)
98
- Net.http_session(options) do |http|
99
- resp = http.request(Ronin::Network::HTTP.request(:copy,options))
160
+ resp = Net.http_request(options.merge(:method => :copy))
100
161
 
101
- block.call(resp) if block
102
- return resp
103
- end
162
+ block.call(resp) if block
163
+ return resp
104
164
  end
105
165
 
106
166
  #
@@ -108,16 +168,45 @@ module Net
108
168
  # is given, it will be passed the response from the HTTP server.
109
169
  # Returns the response from the HTTP server.
110
170
  #
171
+ # _options_ may contain the following keys:
172
+ # <tt>:url</tt>:: The full URL to request.
173
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
174
+ # HTTP server.
175
+ # <tt>:password</tt>:: The password to authenticate with when connecting
176
+ # to the HTTP server.
177
+ # <tt>:host</tt>:: The host the HTTP server is running on.
178
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
179
+ # <tt>Net::HTTP.default_port</tt>.
180
+ # <tt>:path</tt>:: The path to request from the HTTP server.
181
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
182
+ # the HTTP server. Defaults to
183
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
184
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
185
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
186
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
187
+ # <tt>:user</tt>:: The user to authenticate with
188
+ # when connecting to the HTTP proxy.
189
+ # <tt>:password</tt>:: The password to authenticate with
190
+ # when connecting to the HTTP
191
+ # proxy.
192
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
193
+ # Delete request. May use Strings or Symbols for the
194
+ # keys of the Hash.
195
+ #
111
196
  def Net.http_delete(options={},&block)
112
- Net.http_session(options) do |http|
113
- req = Ronin::Network::HTTP.request(:delete,options)
114
- req['Depth'] = (options[:depth].to_s || 'Infinity')
197
+ original_headers = options[:headers]
115
198
 
116
- resp = http.request(req)
199
+ # set the HTTP Depth header
200
+ options[:headers] = {:depth => 'Infinity'}
117
201
 
118
- block.call(resp) if block
119
- return resp
202
+ if original_headers
203
+ options[:header].merge!(original_headers)
120
204
  end
205
+
206
+ resp = Net.http_request(options.merge(:method => :delete))
207
+
208
+ block.call(resp) if block
209
+ return resp
121
210
  end
122
211
 
123
212
  #
@@ -125,13 +214,36 @@ module Net
125
214
  # is given, it will be passed the response from the HTTP server.
126
215
  # Returns the response from the HTTP server.
127
216
  #
217
+ # _options_ may contain the following keys:
218
+ # <tt>:url</tt>:: The full URL to request.
219
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
220
+ # HTTP server.
221
+ # <tt>:password</tt>:: The password to authenticate with when connecting
222
+ # to the HTTP server.
223
+ # <tt>:host</tt>:: The host the HTTP server is running on.
224
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
225
+ # <tt>Net::HTTP.default_port</tt>.
226
+ # <tt>:path</tt>:: The path to request from the HTTP server.
227
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
228
+ # the HTTP server. Defaults to
229
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
230
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
231
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
232
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
233
+ # <tt>:user</tt>:: The user to authenticate with
234
+ # when connecting to the HTTP proxy.
235
+ # <tt>:password</tt>:: The password to authenticate with
236
+ # when connecting to the HTTP
237
+ # proxy.
238
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
239
+ # Get request. May use Strings or Symbols for the
240
+ # keys of the Hash.
241
+ #
128
242
  def Net.http_get(options={},&block)
129
- Net.http_session(options) do |http|
130
- resp = http.request(Ronin::Network::HTTP.request(:get,options))
243
+ resp = Net.http_request(options.merge(:method => :get))
131
244
 
132
- block.call(resp) if block
133
- return resp
134
- end
245
+ block.call(resp) if block
246
+ return resp
135
247
  end
136
248
 
137
249
  #
@@ -139,6 +251,31 @@ module Net
139
251
  # is given, it will be passed the response body from the HTTP server.
140
252
  # Returns the response body from the HTTP server.
141
253
  #
254
+ # _options_ may contain the following keys:
255
+ # <tt>:url</tt>:: The full URL to request.
256
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
257
+ # HTTP server.
258
+ # <tt>:password</tt>:: The password to authenticate with when connecting
259
+ # to the HTTP server.
260
+ # <tt>:host</tt>:: The host the HTTP server is running on.
261
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
262
+ # <tt>Net::HTTP.default_port</tt>.
263
+ # <tt>:path</tt>:: The path to request from the HTTP server.
264
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
265
+ # the HTTP server. Defaults to
266
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
267
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
268
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
269
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
270
+ # <tt>:user</tt>:: The user to authenticate with
271
+ # when connecting to the HTTP proxy.
272
+ # <tt>:password</tt>:: The password to authenticate with
273
+ # when connecting to the HTTP
274
+ # proxy.
275
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
276
+ # Get request. May use Strings or Symbols for the
277
+ # keys of the Hash.
278
+ #
142
279
  def Net.http_get_body(options={},&block)
143
280
  Net.http_get(options,&block).body
144
281
  end
@@ -148,25 +285,100 @@ module Net
148
285
  # is given, it will be passed the response from the HTTP server.
149
286
  # Returns the response from the HTTP server.
150
287
  #
288
+ # _options_ may contain the following keys:
289
+ # <tt>:url</tt>:: The full URL to request.
290
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
291
+ # HTTP server.
292
+ # <tt>:password</tt>:: The password to authenticate with when connecting
293
+ # to the HTTP server.
294
+ # <tt>:host</tt>:: The host the HTTP server is running on.
295
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
296
+ # <tt>Net::HTTP.default_port</tt>.
297
+ # <tt>:path</tt>:: The path to request from the HTTP server.
298
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
299
+ # the HTTP server. Defaults to
300
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
301
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
302
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
303
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
304
+ # <tt>:user</tt>:: The user to authenticate with
305
+ # when connecting to the HTTP proxy.
306
+ # <tt>:password</tt>:: The password to authenticate with
307
+ # when connecting to the HTTP
308
+ # proxy.
309
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
310
+ # Head request. May use Strings or Symbols for the
311
+ # keys of the Hash.
312
+ #
151
313
  def Net.http_head(options={},&block)
152
- Net.http_session(options) do |http|
153
- resp = http.request(Ronin::Network::HTTP.request(:head,options))
314
+ resp = Net.http_request(options.merge(:method => :head))
154
315
 
155
- block.call(resp) if block
156
- return resp
157
- end
316
+ block.call(resp) if block
317
+ return resp
158
318
  end
159
319
 
160
320
  #
161
321
  # Returns +true+ if a HTTP Head request with the given _options_ returns
162
322
  # the HTTP status code of 200, returns +false+ otherwise.
163
323
  #
324
+ # _options_ may contain the following keys:
325
+ # <tt>:url</tt>:: The full URL to request.
326
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
327
+ # HTTP server.
328
+ # <tt>:password</tt>:: The password to authenticate with when connecting
329
+ # to the HTTP server.
330
+ # <tt>:host</tt>:: The host the HTTP server is running on.
331
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
332
+ # <tt>Net::HTTP.default_port</tt>.
333
+ # <tt>:path</tt>:: The path to request from the HTTP server.
334
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
335
+ # the HTTP server. Defaults to
336
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
337
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
338
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
339
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
340
+ # <tt>:user</tt>:: The user to authenticate with
341
+ # when connecting to the HTTP proxy.
342
+ # <tt>:password</tt>:: The password to authenticate with
343
+ # when connecting to the HTTP
344
+ # proxy.
345
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
346
+ # Head request. May use Strings or Symbols for the
347
+ # keys of the Hash.
348
+ #
349
+ #
164
350
  def Net.http_ok?(options={})
165
351
  Net.http_head(options).code == 200
166
352
  end
167
353
 
168
354
  #
169
- # Returns the HTTP Server header for the given _options_.
355
+ # Sends a HTTP Head request using the given _options_ and returns the
356
+ # HTTP Server header.
357
+ #
358
+ # _options_ may contain the following keys:
359
+ # <tt>:url</tt>:: The full URL to request.
360
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
361
+ # HTTP server.
362
+ # <tt>:password</tt>:: The password to authenticate with when connecting
363
+ # to the HTTP server.
364
+ # <tt>:host</tt>:: The host the HTTP server is running on.
365
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
366
+ # <tt>Net::HTTP.default_port</tt>.
367
+ # <tt>:path</tt>:: The path to request from the HTTP server.
368
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
369
+ # the HTTP server. Defaults to
370
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
371
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
372
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
373
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
374
+ # <tt>:user</tt>:: The user to authenticate with
375
+ # when connecting to the HTTP proxy.
376
+ # <tt>:password</tt>:: The password to authenticate with
377
+ # when connecting to the HTTP
378
+ # proxy.
379
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
380
+ # Head request. May use Strings or Symbols for the
381
+ # keys of the Hash.
170
382
  #
171
383
  # Net.http_server(:url => 'http://www.darkc0de.com/)
172
384
  # # => "Apache/2.2.11 (Unix) PHP/4.4.9 mod_ssl/2.2.11 OpenSSL/0.9.8c
@@ -177,7 +389,33 @@ module Net
177
389
  end
178
390
 
179
391
  #
180
- # Returns the HTTP X-Powered-By header for the given _options_.
392
+ # Sends an HTTP Head request using the given _options_ and returns the
393
+ # HTTP X-Powered-By header.
394
+ #
395
+ # _options_ may contain the following keys:
396
+ # <tt>:url</tt>:: The full URL to request.
397
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
398
+ # HTTP server.
399
+ # <tt>:password</tt>:: The password to authenticate with when connecting
400
+ # to the HTTP server.
401
+ # <tt>:host</tt>:: The host the HTTP server is running on.
402
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
403
+ # <tt>Net::HTTP.default_port</tt>.
404
+ # <tt>:path</tt>:: The path to request from the HTTP server.
405
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
406
+ # the HTTP server. Defaults to
407
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
408
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
409
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
410
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
411
+ # <tt>:user</tt>:: The user to authenticate with
412
+ # when connecting to the HTTP proxy.
413
+ # <tt>:password</tt>:: The password to authenticate with
414
+ # when connecting to the HTTP
415
+ # proxy.
416
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
417
+ # Head request. May use Strings or Symbols for the
418
+ # keys of the Hash.
181
419
  #
182
420
  # Net.http_powered_by(:url => 'http://www.stalkdaily.com/')
183
421
  # # => "PHP/5.2.9"
@@ -197,13 +435,36 @@ module Net
197
435
  # is given, it will be passed the response from the HTTP server.
198
436
  # Returns the response from the HTTP server.
199
437
  #
438
+ # _options_ may contain the following keys:
439
+ # <tt>:url</tt>:: The full URL to request.
440
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
441
+ # HTTP server.
442
+ # <tt>:password</tt>:: The password to authenticate with when connecting
443
+ # to the HTTP server.
444
+ # <tt>:host</tt>:: The host the HTTP server is running on.
445
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
446
+ # <tt>Net::HTTP.default_port</tt>.
447
+ # <tt>:path</tt>:: The path to request from the HTTP server.
448
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
449
+ # the HTTP server. Defaults to
450
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
451
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
452
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
453
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
454
+ # <tt>:user</tt>:: The user to authenticate with
455
+ # when connecting to the HTTP proxy.
456
+ # <tt>:password</tt>:: The password to authenticate with
457
+ # when connecting to the HTTP
458
+ # proxy.
459
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
460
+ # Lock request. May use Strings or Symbols for the
461
+ # keys of the Hash.
462
+ #
200
463
  def Net.http_lock(options={},&block)
201
- Net.http_session(options) do |http|
202
- resp = http.request(Ronin::Network::HTTP.request(:lock,options),options[:body])
464
+ resp = Net.http_request(options.merge(:method => :lock))
203
465
 
204
- block.call(resp) if block
205
- return resp
206
- end
466
+ block.call(resp) if block
467
+ return resp
207
468
  end
208
469
 
209
470
  #
@@ -211,13 +472,36 @@ module Net
211
472
  # is given, it will be passed the response from the HTTP server.
212
473
  # Returns the response from the HTTP server.
213
474
  #
475
+ # _options_ may contain the following keys:
476
+ # <tt>:url</tt>:: The full URL to request.
477
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
478
+ # HTTP server.
479
+ # <tt>:password</tt>:: The password to authenticate with when connecting
480
+ # to the HTTP server.
481
+ # <tt>:host</tt>:: The host the HTTP server is running on.
482
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
483
+ # <tt>Net::HTTP.default_port</tt>.
484
+ # <tt>:path</tt>:: The path to request from the HTTP server.
485
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
486
+ # the HTTP server. Defaults to
487
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
488
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
489
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
490
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
491
+ # <tt>:user</tt>:: The user to authenticate with
492
+ # when connecting to the HTTP proxy.
493
+ # <tt>:password</tt>:: The password to authenticate with
494
+ # when connecting to the HTTP
495
+ # proxy.
496
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
497
+ # Mkcol request. May use Strings or Symbols for the
498
+ # keys of the Hash.
499
+ #
214
500
  def Net.http_mkcol(options={},&block)
215
- Net.http_session(options) do |http|
216
- resp = http.request(Ronin::Network::HTTP.request(:mkcol,options),options[:body])
501
+ resp = Net.http_request(options.merge(:method => :mkcol))
217
502
 
218
- block.call(resp) if block
219
- return resp
220
- end
503
+ block.call(resp) if block
504
+ return resp
221
505
  end
222
506
 
223
507
  #
@@ -225,13 +509,36 @@ module Net
225
509
  # is given, it will be passed the response from the HTTP server.
226
510
  # Returns the response from the HTTP server.
227
511
  #
512
+ # _options_ may contain the following keys:
513
+ # <tt>:url</tt>:: The full URL to request.
514
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
515
+ # HTTP server.
516
+ # <tt>:password</tt>:: The password to authenticate with when connecting
517
+ # to the HTTP server.
518
+ # <tt>:host</tt>:: The host the HTTP server is running on.
519
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
520
+ # <tt>Net::HTTP.default_port</tt>.
521
+ # <tt>:path</tt>:: The path to request from the HTTP server.
522
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
523
+ # the HTTP server. Defaults to
524
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
525
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
526
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
527
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
528
+ # <tt>:user</tt>:: The user to authenticate with
529
+ # when connecting to the HTTP proxy.
530
+ # <tt>:password</tt>:: The password to authenticate with
531
+ # when connecting to the HTTP
532
+ # proxy.
533
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
534
+ # Move request. May use Strings or Symbols for the
535
+ # keys of the Hash.
536
+ #
228
537
  def Net.http_move(options={},&block)
229
- Net.http_session(options) do |http|
230
- resp = http.request(Ronin::Network::HTTP.request(:move,options))
538
+ resp = Net.http_request(options.merge(:method => :move))
231
539
 
232
- block.call(resp) if block
233
- return resp
234
- end
540
+ block.call(resp) if block
541
+ return resp
235
542
  end
236
543
 
237
544
  #
@@ -239,13 +546,36 @@ module Net
239
546
  # is given, it will be passed the response from the HTTP server.
240
547
  # Returns the response from the HTTP server.
241
548
  #
549
+ # _options_ may contain the following keys:
550
+ # <tt>:url</tt>:: The full URL to request.
551
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
552
+ # HTTP server.
553
+ # <tt>:password</tt>:: The password to authenticate with when connecting
554
+ # to the HTTP server.
555
+ # <tt>:host</tt>:: The host the HTTP server is running on.
556
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
557
+ # <tt>Net::HTTP.default_port</tt>.
558
+ # <tt>:path</tt>:: The path to request from the HTTP server.
559
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
560
+ # the HTTP server. Defaults to
561
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
562
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
563
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
564
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
565
+ # <tt>:user</tt>:: The user to authenticate with
566
+ # when connecting to the HTTP proxy.
567
+ # <tt>:password</tt>:: The password to authenticate with
568
+ # when connecting to the HTTP
569
+ # proxy.
570
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
571
+ # Options request. May use Strings or Symbols for
572
+ # the keys of the Hash.
573
+ #
242
574
  def Net.http_options(options={},&block)
243
- Net.http_session(options) do |http|
244
- resp = http.request(Ronin::Network::HTTP.request(:options,options))
575
+ resp = Net.http_request(options.merge(:method => :options))
245
576
 
246
- block.call(resp) if block
247
- return resp
248
- end
577
+ block.call(resp) if block
578
+ return resp
249
579
  end
250
580
 
251
581
  #
@@ -253,19 +583,47 @@ module Net
253
583
  # is given, it will be passed the response from the HTTP server.
254
584
  # Returns the response from the HTTP server.
255
585
  #
586
+ # _options_ may contain the following keys:
587
+ # <tt>:url</tt>:: The full URL to request.
588
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
589
+ # HTTP server.
590
+ # <tt>:password</tt>:: The password to authenticate with when connecting
591
+ # to the HTTP server.
592
+ # <tt>:host</tt>:: The host the HTTP server is running on.
593
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
594
+ # <tt>Net::HTTP.default_port</tt>.
595
+ # <tt>:path</tt>:: The path to request from the HTTP server.
596
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
597
+ # the HTTP server. Defaults to
598
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
599
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
600
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
601
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
602
+ # <tt>:user</tt>:: The user to authenticate with
603
+ # when connecting to the HTTP proxy.
604
+ # <tt>:password</tt>:: The password to authenticate with
605
+ # when connecting to the HTTP
606
+ # proxy.
607
+ # <tt>:post_data</tt>:: The POSTDATA to send with the HTTP Post request.
608
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
609
+ # Post request. May use Strings or Symbols for the
610
+ # keys of the Hash.
611
+ #
256
612
  def Net.http_post(options={},&block)
257
- Net.http_session(options) do |http|
258
- url = URI(options[:url].to_s)
259
- post_data = (options[:post_data] || url.query_params)
613
+ options = options.merge(:method => :post)
614
+ post_data = options.delete(:post_data)
260
615
 
261
- req = Ronin::Network::HTTP.request(:post,options)
262
- req.set_form_data(post_data)
263
-
264
- resp = http.request(req)
616
+ if options[:url]
617
+ url = URI(options[:url].to_s)
618
+ post_data ||= url.query_params
619
+ end
265
620
 
266
- block.call(resp) if block
267
- return resp
621
+ resp = Net.http_request(options) do |req,expanded_options|
622
+ req.set_form_data(post_data) if post_data
268
623
  end
624
+
625
+ block.call(resp) if block
626
+ return resp
269
627
  end
270
628
 
271
629
  #
@@ -273,6 +631,31 @@ module Net
273
631
  # is given, it will be passed the response body from the HTTP server.
274
632
  # Returns the response body from the HTTP server.
275
633
  #
634
+ # _options_ may contain the following keys:
635
+ # <tt>:url</tt>:: The full URL to request.
636
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
637
+ # HTTP server.
638
+ # <tt>:password</tt>:: The password to authenticate with when connecting
639
+ # to the HTTP server.
640
+ # <tt>:host</tt>:: The host the HTTP server is running on.
641
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
642
+ # <tt>Net::HTTP.default_port</tt>.
643
+ # <tt>:path</tt>:: The path to request from the HTTP server.
644
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
645
+ # the HTTP server. Defaults to
646
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
647
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
648
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
649
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
650
+ # <tt>:user</tt>:: The user to authenticate with
651
+ # when connecting to the HTTP proxy.
652
+ # <tt>:password</tt>:: The password to authenticate with
653
+ # when connecting to the HTTP
654
+ # proxy.
655
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
656
+ # Post request. May use Strings or Symbols for the
657
+ # keys of the Hash.
658
+ #
276
659
  def Net.http_post_body(options={},&block)
277
660
  Net.http_post(options,&block).body
278
661
  end
@@ -282,16 +665,45 @@ module Net
282
665
  # _block_ is given, it will be passed the response from the HTTP server.
283
666
  # Returns the response from the HTTP server.
284
667
  #
668
+ # _options_ may contain the following keys:
669
+ # <tt>:url</tt>:: The full URL to request.
670
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
671
+ # HTTP server.
672
+ # <tt>:password</tt>:: The password to authenticate with when connecting
673
+ # to the HTTP server.
674
+ # <tt>:host</tt>:: The host the HTTP server is running on.
675
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
676
+ # <tt>Net::HTTP.default_port</tt>.
677
+ # <tt>:path</tt>:: The path to request from the HTTP server.
678
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
679
+ # the HTTP server. Defaults to
680
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
681
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
682
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
683
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
684
+ # <tt>:user</tt>:: The user to authenticate with
685
+ # when connecting to the HTTP proxy.
686
+ # <tt>:password</tt>:: The password to authenticate with
687
+ # when connecting to the HTTP
688
+ # proxy.
689
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
690
+ # Propfind request. May use Strings or Symbols for
691
+ # the keys of the Hash.
692
+ #
285
693
  def Net.http_prop_find(options={},&block)
286
- Net.http_session(options) do |http|
287
- req = Ronin::Network::HTTP.request(:propfind,options)
288
- req['Depth'] = (options[:depth] || '0')
694
+ original_headers = options[:headers]
289
695
 
290
- resp = http.request(req,options[:body])
696
+ # set the HTTP Depth header
697
+ options[:headers] = {:depth => '0'}
291
698
 
292
- block.call(resp) if block
293
- return resp
699
+ if original_headers
700
+ options[:header].merge!(original_headers)
294
701
  end
702
+
703
+ resp = Net.http_request(options.merge(:method => :propfind))
704
+
705
+ block.call(resp) if block
706
+ return resp
295
707
  end
296
708
 
297
709
  #
@@ -299,13 +711,36 @@ module Net
299
711
  # _block_ is given, it will be passed the response from the HTTP server.
300
712
  # Returns the response from the HTTP server.
301
713
  #
714
+ # _options_ may contain the following keys:
715
+ # <tt>:url</tt>:: The full URL to request.
716
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
717
+ # HTTP server.
718
+ # <tt>:password</tt>:: The password to authenticate with when connecting
719
+ # to the HTTP server.
720
+ # <tt>:host</tt>:: The host the HTTP server is running on.
721
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
722
+ # <tt>Net::HTTP.default_port</tt>.
723
+ # <tt>:path</tt>:: The path to request from the HTTP server.
724
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
725
+ # the HTTP server. Defaults to
726
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
727
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
728
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
729
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
730
+ # <tt>:user</tt>:: The user to authenticate with
731
+ # when connecting to the HTTP proxy.
732
+ # <tt>:password</tt>:: The password to authenticate with
733
+ # when connecting to the HTTP
734
+ # proxy.
735
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
736
+ # Proppatch request. May use Strings or Symbols for
737
+ # the keys of the Hash.
738
+ #
302
739
  def Net.http_prop_patch(options={},&block)
303
- Net.http_session(options) do |http|
304
- resp = http.request(Ronin::Network::HTTP.request(:proppatch,options),options[:body])
740
+ resp = Net.http_request(options.merge(:method => :proppatch))
305
741
 
306
- block.call(resp) if block
307
- return resp
308
- end
742
+ block.call(resp) if block
743
+ return resp
309
744
  end
310
745
 
311
746
  #
@@ -313,13 +748,36 @@ module Net
313
748
  # is given, it will be passed the response from the HTTP server.
314
749
  # Returns the response from the HTTP server.
315
750
  #
751
+ # _options_ may contain the following keys:
752
+ # <tt>:url</tt>:: The full URL to request.
753
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
754
+ # HTTP server.
755
+ # <tt>:password</tt>:: The password to authenticate with when connecting
756
+ # to the HTTP server.
757
+ # <tt>:host</tt>:: The host the HTTP server is running on.
758
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
759
+ # <tt>Net::HTTP.default_port</tt>.
760
+ # <tt>:path</tt>:: The path to request from the HTTP server.
761
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
762
+ # the HTTP server. Defaults to
763
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
764
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
765
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
766
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
767
+ # <tt>:user</tt>:: The user to authenticate with
768
+ # when connecting to the HTTP proxy.
769
+ # <tt>:password</tt>:: The password to authenticate with
770
+ # when connecting to the HTTP
771
+ # proxy.
772
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
773
+ # Trace request. May use Strings or Symbols for the
774
+ # keys of the Hash.
775
+ #
316
776
  def Net.http_trace(options={},&block)
317
- Net.http_session(options) do |http|
318
- resp = http.request(Ronin::Network::HTTP.request(:trace,options))
777
+ resp = Net.http_request(options.merge(:method => :trace))
319
778
 
320
- block.call(resp) if block
321
- return resp
322
- end
779
+ block.call(resp) if block
780
+ return resp
323
781
  end
324
782
 
325
783
  #
@@ -327,12 +785,35 @@ module Net
327
785
  # is given, it will be passed the response from the HTTP server.
328
786
  # Returns the response from the HTTP server.
329
787
  #
788
+ # _options_ may contain the following keys:
789
+ # <tt>:url</tt>:: The full URL to request.
790
+ # <tt>:user</tt>:: The user to authenticate with when connecting to the
791
+ # HTTP server.
792
+ # <tt>:password</tt>:: The password to authenticate with when connecting
793
+ # to the HTTP server.
794
+ # <tt>:host</tt>:: The host the HTTP server is running on.
795
+ # <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
796
+ # <tt>Net::HTTP.default_port</tt>.
797
+ # <tt>:path</tt>:: The path to request from the HTTP server.
798
+ # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
799
+ # the HTTP server. Defaults to
800
+ # <tt>Ronin::Network::HTTP.proxy</tt>.
801
+ # <tt>:host</tt>:: The HTTP proxy host to connect to.
802
+ # <tt>:port</tt>:: The HTTP proxy port to connect to.
803
+ # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
804
+ # <tt>:user</tt>:: The user to authenticate with
805
+ # when connecting to the HTTP proxy.
806
+ # <tt>:password</tt>:: The password to authenticate with
807
+ # when connecting to the HTTP
808
+ # proxy.
809
+ # <tt>:headers</tt>:: A Hash of the HTTP Headers to send with the HTTP
810
+ # Unlock request. May use Strings or Symbols for the
811
+ # keys of the Hash.
812
+ #
330
813
  def Net.http_unlock(options={},&block)
331
- Net.http_session(options) do |http|
332
- resp = http.request(Ronin::Network::HTTP.request(:unlock,options),options[:body])
814
+ resp = Net.http_request(options.merge(:method => :unlock))
333
815
 
334
- block.call(resp) if block
335
- return resp
336
- end
816
+ block.call(resp) if block
817
+ return resp
337
818
  end
338
819
  end