ronin 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +95 -0
  3. data/Manifest.txt +55 -25
  4. data/README.txt +64 -52
  5. data/Rakefile +21 -14
  6. data/bin/ronin +1 -1
  7. data/bin/ronin-add +1 -1
  8. data/bin/ronin-console +1 -1
  9. data/bin/ronin-help +1 -1
  10. data/bin/ronin-install +1 -1
  11. data/bin/ronin-list +1 -1
  12. data/bin/ronin-remove +1 -1
  13. data/bin/ronin-uninstall +1 -1
  14. data/bin/ronin-update +1 -1
  15. data/lib/ronin.rb +2 -4
  16. data/lib/ronin/arch.rb +66 -21
  17. data/lib/ronin/author.rb +27 -18
  18. data/lib/ronin/cacheable.rb +63 -23
  19. data/lib/ronin/code/emittable.rb +1 -4
  20. data/lib/ronin/code/reference.rb +2 -5
  21. data/lib/ronin/code/symbol_table.rb +1 -4
  22. data/lib/ronin/code/token.rb +1 -4
  23. data/lib/ronin/config.rb +31 -10
  24. data/lib/ronin/database.rb +1 -4
  25. data/lib/ronin/database/database.rb +42 -23
  26. data/lib/ronin/database/exceptions.rb +1 -4
  27. data/lib/ronin/database/exceptions/invalid_config.rb +1 -4
  28. data/lib/ronin/environment.rb +1 -5
  29. data/lib/ronin/extensions.rb +1 -5
  30. data/lib/ronin/extensions/array.rb +8 -6
  31. data/lib/ronin/extensions/file.rb +9 -4
  32. data/lib/ronin/extensions/ip_addr.rb +33 -13
  33. data/lib/ronin/extensions/kernel.rb +44 -9
  34. data/lib/ronin/extensions/meta.rb +1 -4
  35. data/lib/ronin/extensions/string.rb +8 -7
  36. data/lib/ronin/extensions/uri.rb +1 -4
  37. data/lib/ronin/extensions/uri/http.rb +1 -48
  38. data/lib/ronin/extensions/uri/query_params.rb +27 -8
  39. data/lib/ronin/formatting.rb +1 -4
  40. data/lib/ronin/formatting/binary.rb +1 -4
  41. data/lib/ronin/formatting/digest.rb +1 -4
  42. data/lib/ronin/formatting/extensions.rb +1 -4
  43. data/lib/ronin/formatting/extensions/binary.rb +1 -4
  44. data/lib/ronin/formatting/extensions/binary/file.rb +3 -28
  45. data/lib/ronin/formatting/extensions/binary/integer.rb +31 -12
  46. data/lib/ronin/formatting/extensions/binary/string.rb +59 -36
  47. data/lib/ronin/formatting/extensions/digest.rb +1 -4
  48. data/lib/ronin/formatting/extensions/digest/string.rb +31 -9
  49. data/lib/ronin/formatting/extensions/http.rb +1 -4
  50. data/lib/ronin/formatting/extensions/http/string.rb +16 -9
  51. data/lib/ronin/formatting/extensions/text.rb +1 -4
  52. data/lib/ronin/formatting/extensions/text/array.rb +17 -7
  53. data/lib/ronin/formatting/extensions/text/string.rb +70 -27
  54. data/lib/ronin/formatting/http.rb +1 -4
  55. data/lib/ronin/formatting/text.rb +1 -4
  56. data/lib/ronin/license.rb +72 -65
  57. data/lib/ronin/model.rb +1 -4
  58. data/lib/ronin/model/has_description.rb +37 -8
  59. data/lib/ronin/model/has_license.rb +12 -8
  60. data/lib/ronin/model/has_name.rb +10 -7
  61. data/lib/ronin/model/has_version.rb +14 -4
  62. data/lib/ronin/model/model.rb +71 -14
  63. data/lib/ronin/network.rb +1 -4
  64. data/lib/ronin/network/esmtp.rb +1 -4
  65. data/lib/ronin/network/extensions.rb +1 -4
  66. data/lib/ronin/network/extensions/esmtp.rb +1 -4
  67. data/lib/ronin/network/extensions/esmtp/net.rb +49 -21
  68. data/lib/ronin/network/extensions/http.rb +1 -4
  69. data/lib/ronin/network/extensions/http/net.rb +319 -531
  70. data/lib/ronin/network/extensions/imap.rb +1 -4
  71. data/lib/ronin/network/extensions/imap/net.rb +50 -23
  72. data/lib/ronin/network/extensions/pop3.rb +1 -4
  73. data/lib/ronin/network/extensions/pop3/net.rb +40 -17
  74. data/lib/ronin/network/extensions/smtp.rb +1 -4
  75. data/lib/ronin/network/extensions/smtp/net.rb +49 -21
  76. data/lib/ronin/network/extensions/tcp.rb +1 -4
  77. data/lib/ronin/network/extensions/tcp/net.rb +234 -31
  78. data/lib/ronin/network/extensions/telnet.rb +1 -4
  79. data/lib/ronin/network/extensions/telnet/net.rb +83 -51
  80. data/lib/ronin/network/extensions/udp.rb +1 -4
  81. data/lib/ronin/network/extensions/udp/net.rb +164 -27
  82. data/lib/ronin/{sessions.rb → network/helpers.rb} +10 -13
  83. data/lib/ronin/network/helpers/esmtp.rb +129 -0
  84. data/lib/ronin/{sessions/session.rb → network/helpers/helper.rb} +25 -17
  85. data/lib/ronin/network/helpers/http.rb +444 -0
  86. data/lib/ronin/network/helpers/imap.rb +115 -0
  87. data/lib/ronin/network/helpers/pop3.rb +110 -0
  88. data/lib/ronin/network/helpers/smtp.rb +123 -0
  89. data/lib/ronin/network/helpers/tcp.rb +309 -0
  90. data/lib/ronin/network/helpers/telnet.rb +158 -0
  91. data/lib/ronin/network/helpers/udp.rb +197 -0
  92. data/lib/ronin/network/http.rb +3 -156
  93. data/lib/ronin/network/http/exceptions.rb +1 -4
  94. data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -4
  95. data/lib/ronin/network/http/http.rb +214 -0
  96. data/lib/ronin/network/http/proxy.rb +308 -0
  97. data/lib/ronin/network/imap.rb +7 -6
  98. data/lib/ronin/network/pop3.rb +7 -6
  99. data/lib/ronin/network/smtp.rb +1 -4
  100. data/lib/ronin/network/smtp/email.rb +34 -18
  101. data/lib/ronin/network/smtp/smtp.rb +19 -7
  102. data/lib/ronin/network/tcp.rb +1 -4
  103. data/lib/ronin/network/telnet.rb +25 -12
  104. data/lib/ronin/network/udp.rb +1 -4
  105. data/lib/ronin/os.rb +43 -21
  106. data/lib/ronin/path.rb +29 -9
  107. data/lib/ronin/platform.rb +1 -4
  108. data/lib/ronin/platform/exceptions.rb +1 -4
  109. data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -4
  110. data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -4
  111. data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -4
  112. data/lib/ronin/platform/extension.rb +195 -52
  113. data/lib/ronin/platform/extension_cache.rb +60 -24
  114. data/lib/ronin/platform/maintainer.rb +15 -8
  115. data/lib/ronin/platform/object_cache.rb +29 -8
  116. data/lib/ronin/platform/overlay.rb +82 -26
  117. data/lib/ronin/platform/overlay_cache.rb +179 -56
  118. data/lib/ronin/platform/platform.rb +154 -58
  119. data/lib/ronin/platform/ronin.rb +38 -11
  120. data/lib/ronin/product.rb +17 -17
  121. data/lib/ronin/rpc.rb +1 -4
  122. data/lib/ronin/rpc/call.rb +1 -4
  123. data/lib/ronin/rpc/client.rb +1 -4
  124. data/lib/ronin/rpc/console.rb +1 -4
  125. data/lib/ronin/rpc/exceptions.rb +1 -4
  126. data/lib/ronin/rpc/exceptions/not_implemented.rb +1 -4
  127. data/lib/ronin/rpc/exceptions/response_missing.rb +1 -4
  128. data/lib/ronin/rpc/response.rb +1 -4
  129. data/lib/ronin/rpc/service.rb +1 -4
  130. data/lib/ronin/rpc/shell.rb +1 -4
  131. data/lib/ronin/scanners.rb +1 -4
  132. data/lib/ronin/scanners/exceptions.rb +1 -4
  133. data/lib/ronin/scanners/exceptions/unknown_category.rb +1 -4
  134. data/lib/ronin/scanners/scanner.rb +82 -26
  135. data/lib/ronin/static.rb +1 -4
  136. data/lib/ronin/static/finders.rb +1 -4
  137. data/lib/ronin/static/static.rb +16 -7
  138. data/lib/ronin/templates.rb +2 -4
  139. data/lib/ronin/templates/erb.rb +24 -10
  140. data/lib/ronin/templates/template.rb +130 -0
  141. data/lib/ronin/ui.rb +2 -6
  142. data/lib/ronin/ui/command_line.rb +1 -4
  143. data/lib/ronin/ui/command_line/command.rb +137 -68
  144. data/lib/ronin/ui/command_line/command_line.rb +52 -29
  145. data/lib/ronin/ui/command_line/commands/add.rb +39 -67
  146. data/lib/ronin/ui/command_line/commands/console.rb +23 -27
  147. data/lib/ronin/ui/command_line/commands/help.rb +10 -29
  148. data/lib/ronin/ui/command_line/commands/install.rb +31 -56
  149. data/lib/ronin/ui/command_line/commands/list.rb +34 -52
  150. data/lib/ronin/ui/command_line/commands/remove.rb +12 -32
  151. data/lib/ronin/ui/command_line/commands/uninstall.rb +11 -31
  152. data/lib/ronin/ui/command_line/commands/update.rb +15 -35
  153. data/lib/ronin/ui/command_line/exceptions.rb +1 -4
  154. data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -4
  155. data/lib/ronin/ui/console.rb +54 -23
  156. data/lib/ronin/ui/hexdump.rb +1 -4
  157. data/lib/ronin/ui/hexdump/extensions.rb +1 -4
  158. data/lib/ronin/ui/hexdump/extensions/file.rb +8 -6
  159. data/lib/ronin/ui/hexdump/extensions/kernel.rb +4 -5
  160. data/lib/ronin/ui/hexdump/hexdump.rb +8 -5
  161. data/lib/ronin/{sessions/exceptions.rb → ui/output.rb} +3 -5
  162. data/lib/ronin/ui/output/handler.rb +121 -0
  163. data/lib/ronin/ui/output/helpers.rb +110 -0
  164. data/lib/ronin/ui/output/output.rb +144 -0
  165. data/lib/ronin/ui/shell.rb +38 -12
  166. data/lib/ronin/version.rb +2 -5
  167. data/lib/ronin/{sessions/exceptions/variable_missing.rb → yard.rb} +2 -10
  168. data/lib/ronin/{ronin.rb → yard/handlers.rb} +5 -15
  169. data/lib/ronin/yard/handlers/ruby.rb +27 -0
  170. data/lib/ronin/yard/handlers/ruby/base.rb +27 -0
  171. data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +45 -0
  172. data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +18 -0
  173. data/lib/ronin/yard/handlers/ruby/has_handler.rb +49 -0
  174. data/lib/ronin/yard/handlers/ruby/legacy.rb +26 -0
  175. data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +41 -0
  176. data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +19 -0
  177. data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +34 -0
  178. data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +21 -0
  179. data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +41 -0
  180. data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +61 -0
  181. data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +18 -0
  182. data/lib/ronin/yard/handlers/ruby/property_handler.rb +45 -0
  183. data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +66 -0
  184. data/spec/author_spec.rb +3 -3
  185. data/spec/extensions/classes/some_class.rb +2 -0
  186. data/spec/extensions/kernel_spec.rb +17 -0
  187. data/spec/extensions/uri/http_spec.rb +0 -31
  188. data/spec/formatting/binary/integer_spec.rb +4 -0
  189. data/spec/formatting/text/string_spec.rb +96 -0
  190. data/spec/license_spec.rb +6 -6
  191. data/spec/model/classes/basic_model.rb +13 -0
  192. data/spec/model/classes/custom_model.rb +17 -0
  193. data/spec/model/classes/described_model.rb +10 -0
  194. data/spec/model/has_description_spec.rb +42 -0
  195. data/spec/model/has_license_spec.rb +18 -4
  196. data/spec/model/model_spec.rb +68 -0
  197. data/spec/network/helpers/classes/test_helper.rb +11 -0
  198. data/spec/network/helpers/classes/uses_test_helper.rb +10 -0
  199. data/spec/network/helpers/helper_spec.rb +25 -0
  200. data/spec/network/{http_spec.rb → http/http_spec.rb} +0 -0
  201. data/spec/network/http/proxy_spec.rb +116 -0
  202. data/spec/os_spec.rb +4 -4
  203. data/spec/platform/extension_cache_spec.rb +14 -0
  204. data/spec/platform/extension_spec.rb +11 -0
  205. data/spec/platform/platform_spec.rb +8 -0
  206. data/spec/product_spec.rb +9 -9
  207. data/spec/spec_helper.rb +1 -1
  208. data/spec/templates/classes/{uses_erb.rb → example_erb.rb} +1 -1
  209. data/spec/templates/classes/example_template.rb +21 -0
  210. data/spec/templates/erb_spec.rb +2 -2
  211. data/spec/templates/helpers/static.rb +5 -0
  212. data/spec/templates/helpers/static/templates/_relative.erb +1 -0
  213. data/spec/templates/helpers/static/templates/example.erb +1 -0
  214. data/spec/templates/template_spec.rb +41 -0
  215. data/spec/ui/command_line/classes/test_command.rb +23 -0
  216. data/spec/ui/command_line/command_spec.rb +31 -0
  217. data/spec/ui/output_spec.rb +29 -0
  218. data/static/ronin/platform/overlay.xsl +135 -114
  219. data/tasks/spec.rb +1 -0
  220. data/tasks/yard.rb +18 -0
  221. metadata +98 -59
  222. metadata.gz.sig +0 -0
  223. data/TODO.txt +0 -15
  224. data/lib/ronin/extensions/hash.rb +0 -62
  225. data/lib/ronin/sessions/esmtp.rb +0 -57
  226. data/lib/ronin/sessions/http.rb +0 -678
  227. data/lib/ronin/sessions/imap.rb +0 -54
  228. data/lib/ronin/sessions/pop3.rb +0 -52
  229. data/lib/ronin/sessions/smtp.rb +0 -57
  230. data/lib/ronin/sessions/tcp.rb +0 -100
  231. data/lib/ronin/sessions/telnet.rb +0 -55
  232. data/lib/ronin/sessions/udp.rb +0 -73
  233. data/lib/ronin/ui/command_line/options.rb +0 -136
  234. data/lib/ronin/ui/diagnostics.rb +0 -66
  235. data/lib/ronin/ui/verbose.rb +0 -58
  236. data/spec/extensions/hash_spec.rb +0 -38
  237. data/spec/sessions/classes/test_session.rb +0 -11
  238. data/spec/sessions/classes/uses_test_session.rb +0 -10
  239. data/spec/sessions/session_spec.rb +0 -25
  240. data/spec/ui/verbose_spec.rb +0 -17
data/lib/ronin/network.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,7 +16,6 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/network/tcp'
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,7 +16,6 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/network/extensions/esmtp'
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,7 +16,6 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/network/extensions/tcp'
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,7 +16,6 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/network/extensions/esmtp/net'
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,33 +16,51 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/network/extensions/smtp'
25
22
 
26
23
  module Net
27
24
  #
28
- # See <tt>Ronin::Network::SMTP.message</tt>.
25
+ # @see Ronin::Network::SMTP.message
29
26
  #
30
27
  def Net.esmtp_message(options={},&block)
31
28
  Net.smtp_message(options,&block)
32
29
  end
33
30
 
34
31
  #
35
- # Connects to the ESMTP server on the specified _host_ with the given
36
- # _options_. If a _block_ is given it will be passed the newly created
37
- # <tt>Net::SMTP</tt> object.
32
+ # Creates a connection to the ESMTP server.
38
33
  #
39
- # _options_ may contain the following keys:
40
- # <tt>:port</tt>:: The port to connect to, defaults to
41
- # <tt>Ronin::Network::SMTP.default_port</tt>.
42
- # <tt>:helo</tt>:: The HELO domain.
43
- # <tt>:auth</tt>:: The type of authentication to use. Can be
44
- # either <tt>:login</tt>, <tt>:plain</tt> or
45
- # <tt>:cram_md5</tt>.
46
- # <tt>:user</tt>:: The user name to authenticate with.
47
- # <tt>:password</tt>:: The password to authenticate with.
34
+ # @param [String] host
35
+ # The host to connect to.
36
+ #
37
+ # @param [Hash] options
38
+ # Additional options.
39
+ #
40
+ # @option options [Integer] :port (Ronin::Network::SMTP.default_port)
41
+ # The port to connect to.
42
+ #
43
+ # @option options [String] :helo
44
+ # The HELO domain.
45
+ #
46
+ # @option options [Symbol] :auth
47
+ # The type of authentication to use. Can be either +:login+, +:plain+,
48
+ # or +:cram_md5+.
49
+ #
50
+ # @option options [String] :user
51
+ # The user-name to authenticate with.
52
+ #
53
+ # @option options [String] :password
54
+ # The password to authenticate with.
55
+ #
56
+ # @yield [session]
57
+ # If a block is given, it will be passed an ESMTP enabled session object.
58
+ #
59
+ # @yieldparam [Net::SMTP] session
60
+ # The ESMTP session.
61
+ #
62
+ # @return [Net::SMTP]
63
+ # The ESMTP enabled session.
48
64
  #
49
65
  def Net.esmtp_connect(host,options={},&block)
50
66
  Net.smtp_connect(host,options) do |sess|
@@ -54,10 +70,22 @@ module Net
54
70
  end
55
71
 
56
72
  #
57
- # Connects to the ESMTP server on the specified _host_ with the given
58
- # _options_. If a _block_ is given it will be passed the newly created
59
- # <tt>Net::SMTP</tt> object. After the <tt>Net::SMTP</tt> object has been
60
- # passed to the _block_ it will be closed.
73
+ # Starts an ESMTP session with the ESMTP enabled server.
74
+ #
75
+ # @param [String] host
76
+ # The host to connect to.
77
+ #
78
+ # @param [Hash] options
79
+ # Additional options.
80
+ #
81
+ # @yield [session]
82
+ # If a block is given, it will be passed an ESMTP enabled session
83
+ # object. After the block has returned, the session will be closed.
84
+ #
85
+ # @yieldparam [Net::SMTP] session
86
+ # The ESMTP session.
87
+ #
88
+ # @see Net.esmtp_connect
61
89
  #
62
90
  def Net.esmtp_session(host,options={},&block)
63
91
  Net.smtp_session(host,options) do |sess|
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,7 +16,6 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/network/extensions/http/net'
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,7 +16,6 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/network/http'
@@ -28,30 +25,41 @@ require 'net/http'
28
25
 
29
26
  module Net
30
27
  #
31
- # Connects to the HTTP server using the given _options_. If a _block_
32
- # is given it will be passed the newly created <tt>Net::HTTP</tt> object.
33
- #
34
- # _options_ may contain the following keys:
35
- # <tt>:url</tt>:: The full URL to request.
36
- # <tt>:user</tt>:: The user to authenticate with when connecting to the
37
- # HTTP server.
38
- # <tt>:password</tt>:: The password to authenticate with when connecting
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
- # <tt>:path</tt>:: The path to request from the HTTP server.
44
- # <tt>:proxy</tt>:: A Hash of proxy settings to use when connecting to
45
- # the HTTP server. Defaults to
46
- # <tt>Ronin::Network::HTTP.proxy</tt>.
47
- # <tt>:host</tt>:: The HTTP proxy host to connect to.
48
- # <tt>:port</tt>:: The HTTP proxy port to connect to.
49
- # Defaults to <tt>Ronin::Network::HTTP.default_proxy_port</tt>.
50
- # <tt>:user</tt>:: The user to authenticate with
51
- # when connecting to the HTTP proxy.
52
- # <tt>:password</tt>:: The password to authenticate with
53
- # when connecting to the HTTP
54
- # proxy.
28
+ # Connects to the HTTP server using the given _options_.
29
+ #
30
+ # @param [Hash] options
31
+ # Additional options
32
+ #
33
+ # @option options [String, URI::HTTP] :url
34
+ # The full URL to request.
35
+ #
36
+ # @option options [String] :user
37
+ # The user to authenticate with when connecting to the HTTP server.
38
+ #
39
+ # @option options [String] :password
40
+ # The password to authenticate with when connecting to the HTTP server.
41
+ #
42
+ # @option options [String] :host
43
+ # The host the HTTP server is running on.
44
+ #
45
+ # @option options [Integer] :port (Net::HTTP.default_port)
46
+ # The port the HTTP server is listening on.
47
+ #
48
+ # @option options [String] :path
49
+ # The path to request from the HTTP server.
50
+ #
51
+ # @option options [String, Hash] :proxy (Ronin::Network::HTTP.proxy)
52
+ # A Hash of proxy settings to use when connecting to the HTTP server.
53
+ #
54
+ # @yield [session]
55
+ # If a block is given, it will be passed the newly created HTTP
56
+ # session object.
57
+ #
58
+ # @yieldparam [Net::HTTP] session
59
+ # The newly created HTTP session.
60
+ #
61
+ # @return [Net::HTTP]
62
+ # The HTTP session object.
55
63
  #
56
64
  def Net.http_session(options={},&block)
57
65
  options = Ronin::Network::HTTP.expand_options(options)
@@ -76,33 +84,33 @@ module Net
76
84
  #
77
85
  # Connects to the HTTP server and sends an HTTP Request using the given
78
86
  # _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.
87
+ # HTTP Request object.
88
+ #
89
+ # @param [Hash] options
90
+ # Additional options.
91
+ #
92
+ # @option options [Symbol, String] :method
93
+ # The HTTP method to use in the request.
94
+ #
95
+ # @option options [Hash] :headers
96
+ # The Hash of the HTTP headers to send with the request.
97
+ # May contain either Strings or Symbols, lower-case or camel-case keys.
98
+ #
99
+ # @yield [request, (options)]
100
+ # If a block is given, it will be passed the HTTP request object.
101
+ # If the block has an arity of 2, it will also be passed the expanded
102
+ # version of the given _options_.
103
+ #
104
+ # @yieldparam [Net::HTTP::Request] request
105
+ # The HTTP request object to use in the request.
106
+ #
107
+ # @yieldparam [Hash] options
108
+ # The expanded version of the given _options_.
109
+ #
110
+ # @return [Net::HTTP::Response]
111
+ # The response of the HTTP request.
112
+ #
113
+ # @see http_session
106
114
  #
107
115
  def Net.http_request(options={},&block)
108
116
  resp = nil
@@ -129,32 +137,21 @@ module Net
129
137
  #
130
138
  # Performes an HTTP Copy request with the given _options_. If a _block_
131
139
  # is given, it will be passed the response from the HTTP server.
132
- # Returns the response from the HTTP server.
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.
140
+ #
141
+ # @param [Hash] options
142
+ # Additional options.
143
+ #
144
+ # @yield [response]
145
+ # If a block is given, it will be passed the response received
146
+ # from the request.
147
+ #
148
+ # @yieldparam [Net::HTTP::Response] response
149
+ # The HTTP response object.
150
+ #
151
+ # @return [Net::HTTP::Response]
152
+ # The response of the HTTP request.
153
+ #
154
+ # @see http_request
158
155
  #
159
156
  def Net.http_copy(options={},&block)
160
157
  resp = Net.http_request(options.merge(:method => :copy))
@@ -166,32 +163,21 @@ module Net
166
163
  #
167
164
  # Performes an HTTP Delete request with the given _options_. If a _block_
168
165
  # is given, it will be passed the response from the HTTP server.
169
- # Returns the response from the HTTP server.
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.
166
+ #
167
+ # @param [Hash] options
168
+ # Additional options.
169
+ #
170
+ # @yield [response]
171
+ # If a block is given, it will be passed the response received from
172
+ # the request.
173
+ #
174
+ # @yieldparam [Net::HTTP::Response] response
175
+ # The HTTP response object.
176
+ #
177
+ # @return [Net::HTTP::Response]
178
+ # The response of the HTTP request.
179
+ #
180
+ # @see http_request
195
181
  #
196
182
  def Net.http_delete(options={},&block)
197
183
  original_headers = options[:headers]
@@ -212,32 +198,21 @@ module Net
212
198
  #
213
199
  # Performes an HTTP Get request with the given _options_. If a _block_
214
200
  # is given, it will be passed the response from the HTTP server.
215
- # Returns the response from the HTTP server.
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.
201
+ #
202
+ # @param [Hash] options
203
+ # Additional options.
204
+ #
205
+ # @yield [response]
206
+ # If a block is given, it will be passed the response received from
207
+ # the request.
208
+ #
209
+ # @yieldparam [Net::HTTP::Response] response
210
+ # The HTTP response object.
211
+ #
212
+ # @return [Net::HTTP::Response]
213
+ # The response of the HTTP request.
214
+ #
215
+ # @see http_request
241
216
  #
242
217
  def Net.http_get(options={},&block)
243
218
  resp = Net.http_request(options.merge(:method => :get))
@@ -249,32 +224,21 @@ module Net
249
224
  #
250
225
  # Performes an HTTP Get request with the given _options_. If a _block_
251
226
  # is given, it will be passed the response body from the HTTP server.
252
- # Returns the response body from the HTTP server.
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.
227
+ #
228
+ # @param [Hash] options
229
+ # Additional options.
230
+ #
231
+ # @yield [response]
232
+ # If a block is given, it will be passed the response received from
233
+ # the request.
234
+ #
235
+ # @yieldparam [Net::HTTP::Response] response
236
+ # The HTTP response object.
237
+ #
238
+ # @return [String]
239
+ # The body of the HTTP response.
240
+ #
241
+ # @see http_request
278
242
  #
279
243
  def Net.http_get_body(options={},&block)
280
244
  Net.http_get(options,&block).body
@@ -283,32 +247,21 @@ module Net
283
247
  #
284
248
  # Performes an HTTP Head request with the given _options_. If a _block_
285
249
  # is given, it will be passed the response from the HTTP server.
286
- # Returns the response from the HTTP server.
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.
250
+ #
251
+ # @param [Hash] options
252
+ # Additional options.
253
+ #
254
+ # @yield [response]
255
+ # If a block is given, it will be passed the response received from
256
+ # the request.
257
+ #
258
+ # @yieldparam [Net::HTTP::Response] response
259
+ # The HTTP response object.
260
+ #
261
+ # @return [Net::HTTP::Response]
262
+ # The response of the HTTP request.
263
+ #
264
+ # @see http_request
312
265
  #
313
266
  def Net.http_head(options={},&block)
314
267
  resp = Net.http_request(options.merge(:method => :head))
@@ -318,34 +271,15 @@ module Net
318
271
  end
319
272
 
320
273
  #
321
- # Returns +true+ if a HTTP Head request with the given _options_ returns
322
- # the HTTP status code of 200, returns +false+ otherwise.
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.
274
+ # Checks if the response has an HTTP OK status code.
275
+ #
276
+ # @param [Hash] options
277
+ # Additional options.
348
278
  #
279
+ # @return [Boolean]
280
+ # Specifies wether the response had an HTTP OK status code or not.
281
+ #
282
+ # @see http_request
349
283
  #
350
284
  def Net.http_ok?(options={})
351
285
  Net.http_head(options).code == 200
@@ -355,34 +289,13 @@ module Net
355
289
  # Sends a HTTP Head request using the given _options_ and returns the
356
290
  # HTTP Server header.
357
291
  #
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.
382
- #
383
- # Net.http_server(:url => 'http://www.darkc0de.com/)
384
- # # => "Apache/2.2.11 (Unix) PHP/4.4.9 mod_ssl/2.2.11 OpenSSL/0.9.8c
385
- # mod_fastcgi/2.4.6 Phusion_Passenger/2.1.2 DAV/2 SVN/1.4.2"
292
+ # @param [Hash] options
293
+ # Additional options.
294
+ #
295
+ # @return [String]
296
+ # The HTTP +Server+ header.
297
+ #
298
+ # @see http_request
386
299
  #
387
300
  def Net.http_server(options={})
388
301
  Net.http_head(options)['server']
@@ -392,33 +305,13 @@ module Net
392
305
  # Sends an HTTP Head request using the given _options_ and returns the
393
306
  # HTTP X-Powered-By header.
394
307
  #
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.
419
- #
420
- # Net.http_powered_by(:url => 'http://www.stalkdaily.com/')
421
- # # => "PHP/5.2.9"
308
+ # @param [Hash] options
309
+ # Additional options.
310
+ #
311
+ # @return [String]
312
+ # The HTTP +X-Powered-By+ header.
313
+ #
314
+ # @see http_request
422
315
  #
423
316
  def Net.http_powered_by(options={})
424
317
  resp = Net.http_head(options)
@@ -433,32 +326,21 @@ module Net
433
326
  #
434
327
  # Performes an HTTP Lock request with the given _options_. If a _block_
435
328
  # is given, it will be passed the response from the HTTP server.
436
- # Returns the response from the HTTP server.
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.
329
+ #
330
+ # @param [Hash] options
331
+ # Additional options.
332
+ #
333
+ # @yield [response]
334
+ # If a block is given, it will be passed the response received from
335
+ # the request.
336
+ #
337
+ # @yieldparam [Net::HTTP::Response] response
338
+ # The HTTP response object.
339
+ #
340
+ # @return [Net::HTTP::Response]
341
+ # The response of the HTTP request.
342
+ #
343
+ # @see http_request
462
344
  #
463
345
  def Net.http_lock(options={},&block)
464
346
  resp = Net.http_request(options.merge(:method => :lock))
@@ -470,32 +352,21 @@ module Net
470
352
  #
471
353
  # Performes an HTTP Mkcol request with the given _options_. If a _block_
472
354
  # is given, it will be passed the response from the HTTP server.
473
- # Returns the response from the HTTP server.
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.
355
+ #
356
+ # @param [Hash] options
357
+ # Additional options.
358
+ #
359
+ # @yield [response]
360
+ # If a block is given, it will be passed the response received from
361
+ # the request.
362
+ #
363
+ # @yieldparam [Net::HTTP::Response] response
364
+ # The HTTP response object.
365
+ #
366
+ # @return [Net::HTTP::Response]
367
+ # The response of the HTTP request.
368
+ #
369
+ # @see http_request
499
370
  #
500
371
  def Net.http_mkcol(options={},&block)
501
372
  resp = Net.http_request(options.merge(:method => :mkcol))
@@ -507,32 +378,21 @@ module Net
507
378
  #
508
379
  # Performes an HTTP Move request with the given _options_. If a _block_
509
380
  # is given, it will be passed the response from the HTTP server.
510
- # Returns the response from the HTTP server.
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.
381
+ #
382
+ # @param [Hash] options
383
+ # Additional options.
384
+ #
385
+ # @yield [response]
386
+ # If a block is given, it will be passed the response received from
387
+ # the request.
388
+ #
389
+ # @yieldparam [Net::HTTP::Response] response
390
+ # The HTTP response object.
391
+ #
392
+ # @return [Net::HTTP::Response]
393
+ # The response of the HTTP request.
394
+ #
395
+ # @see http_request
536
396
  #
537
397
  def Net.http_move(options={},&block)
538
398
  resp = Net.http_request(options.merge(:method => :move))
@@ -544,32 +404,21 @@ module Net
544
404
  #
545
405
  # Performes an HTTP Options request with the given _options_. If a _block_
546
406
  # is given, it will be passed the response from the HTTP server.
547
- # Returns the response from the HTTP server.
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.
407
+ #
408
+ # @param [Hash] options
409
+ # Additional options.
410
+ #
411
+ # @yield [response]
412
+ # If a block is given, it will be passed the response received from
413
+ # the request.
414
+ #
415
+ # @yieldparam [Net::HTTP::Response] response
416
+ # The HTTP response object.
417
+ #
418
+ # @return [Net::HTTP::Response]
419
+ # The response of the HTTP request.
420
+ #
421
+ # @see http_request
573
422
  #
574
423
  def Net.http_options(options={},&block)
575
424
  resp = Net.http_request(options.merge(:method => :options))
@@ -581,45 +430,36 @@ module Net
581
430
  #
582
431
  # Performes an HTTP Post request with the given _options_. If a _block_
583
432
  # is given, it will be passed the response from the HTTP server.
584
- # Returns the response from the HTTP server.
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.
433
+ #
434
+ # @param [Hash] options
435
+ # Additional options.
436
+ #
437
+ # @option options [String] :postdata
438
+ # The +POSTDATA+ to send with the HTTP Post request.
439
+ #
440
+ # @yield [response]
441
+ # If a block is given, it will be passed the response received from
442
+ # the request.
443
+ #
444
+ # @yieldparam [Net::HTTP::Response] response
445
+ # The HTTP response object.
446
+ #
447
+ # @return [Net::HTTP::Response]
448
+ # The response of the HTTP request.
449
+ #
450
+ # @see http_request
611
451
  #
612
452
  def Net.http_post(options={},&block)
613
453
  options = options.merge(:method => :post)
614
- post_data = options.delete(:post_data)
454
+ postdata = options.delete(:postdata)
615
455
 
616
456
  if options[:url]
617
457
  url = URI(options[:url].to_s)
618
- post_data ||= url.query_params
458
+ postdata ||= url.query_params
619
459
  end
620
460
 
621
461
  resp = Net.http_request(options) do |req,expanded_options|
622
- req.set_form_data(post_data) if post_data
462
+ req.set_form_data(postdata) if postdata
623
463
  end
624
464
 
625
465
  block.call(resp) if block
@@ -629,32 +469,24 @@ module Net
629
469
  #
630
470
  # Performes an HTTP Post request with the given _options_. If a _block_
631
471
  # is given, it will be passed the response body from the HTTP server.
632
- # Returns the response body from the HTTP server.
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.
472
+ #
473
+ # @param [Hash] options
474
+ # Additional options.
475
+ #
476
+ # @option options [String] :postdata
477
+ # The +POSTDATA+ to send with the HTTP Post request.
478
+ #
479
+ # @yield [response]
480
+ # If a block is given, it will be passed the response received from
481
+ # the request.
482
+ #
483
+ # @yieldparam [Net::HTTP::Response] response
484
+ # The HTTP response object.
485
+ #
486
+ # @return [String]
487
+ # The body of the HTTP response.
488
+ #
489
+ # @see http_request
658
490
  #
659
491
  def Net.http_post_body(options={},&block)
660
492
  Net.http_post(options,&block).body
@@ -663,32 +495,21 @@ module Net
663
495
  #
664
496
  # Performes an HTTP Propfind request with the given _options_. If a
665
497
  # _block_ is given, it will be passed the response from the HTTP server.
666
- # Returns the response from the HTTP server.
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.
498
+ #
499
+ # @param [Hash] options
500
+ # Additional options.
501
+ #
502
+ # @yield [response]
503
+ # If a block is given, it will be passed the response received from
504
+ # the request.
505
+ #
506
+ # @yieldparam [Net::HTTP::Response] response
507
+ # The HTTP response object.
508
+ #
509
+ # @return [Net::HTTP::Response]
510
+ # The response of the HTTP request.
511
+ #
512
+ # @see http_request
692
513
  #
693
514
  def Net.http_prop_find(options={},&block)
694
515
  original_headers = options[:headers]
@@ -709,32 +530,21 @@ module Net
709
530
  #
710
531
  # Performes an HTTP Proppatch request with the given _options_. If a
711
532
  # _block_ is given, it will be passed the response from the HTTP server.
712
- # Returns the response from the HTTP server.
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.
533
+ #
534
+ # @param [Hash] options
535
+ # Additional options.
536
+ #
537
+ # @yield [response]
538
+ # If a block is given, it will be passed the response received from
539
+ # the request.
540
+ #
541
+ # @yieldparam [Net::HTTP::Response] response
542
+ # The HTTP response object.
543
+ #
544
+ # @return [Net::HTTP::Response]
545
+ # The response of the HTTP request.
546
+ #
547
+ # @see http_request
738
548
  #
739
549
  def Net.http_prop_patch(options={},&block)
740
550
  resp = Net.http_request(options.merge(:method => :proppatch))
@@ -746,32 +556,21 @@ module Net
746
556
  #
747
557
  # Performes an HTTP Trace request with the given _options_. If a _block_
748
558
  # is given, it will be passed the response from the HTTP server.
749
- # Returns the response from the HTTP server.
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.
559
+ #
560
+ # @param [Hash] options
561
+ # Additional options.
562
+ #
563
+ # @yield [response]
564
+ # If a block is given, it will be passed the response received from
565
+ # the request.
566
+ #
567
+ # @yieldparam [Net::HTTP::Response] response
568
+ # The HTTP response object.
569
+ #
570
+ # @return [Net::HTTP::Response]
571
+ # The response of the HTTP request.
572
+ #
573
+ # @see http_request
775
574
  #
776
575
  def Net.http_trace(options={},&block)
777
576
  resp = Net.http_request(options.merge(:method => :trace))
@@ -783,32 +582,21 @@ module Net
783
582
  #
784
583
  # Performes an HTTP Unlock request with the given _options_. If a _block_
785
584
  # is given, it will be passed the response from the HTTP server.
786
- # Returns the response from the HTTP server.
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.
585
+ #
586
+ # @param [Hash] options
587
+ # Additional options.
588
+ #
589
+ # @yield [response]
590
+ # If a block is given, it will be passed the response received from
591
+ # the request.
592
+ #
593
+ # @yieldparam [Net::HTTP::Response] response
594
+ # The HTTP response object.
595
+ #
596
+ # @return [Net::HTTP::Response]
597
+ # The response of the HTTP request.
598
+ #
599
+ # @see http_request
812
600
  #
813
601
  def Net.http_unlock(options={},&block)
814
602
  resp = Net.http_request(options.merge(:method => :unlock))