Module: Ronin::Network::Mixins::HTTP
- Includes:
- Mixin
- Defined in:
- lib/ronin/network/mixins/http.rb
Overview
Adds HTTP convenience methods and connection parameters to a class.
Defines the following parameters:
host
(String
) - HTTP host.port
(Integer
) - HTTP port. Defaults toNet::HTTP.default_port
.http_vhost
(String
) - HTTP Host header to send.http_user
(String
) - HTTP user to authenticate as.http_password
(String
) - HTTP password to authenticate with.http_proxy
- HTTP proxy information.http_user_agent
(String
) - HTTP User-Agent header to send.
Instance Method Summary collapse
-
#disable_http_proxy ⇒ Object
protected
Resets the HTTP proxy settings.
-
#http_copy(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Copy request.
-
#http_delete(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Delete request.
-
#http_get(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Get request.
-
#http_get_body(options = {}) {|response| ... } ⇒ String
protected
Performs an HTTP Get request.
-
#http_head(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Head request.
-
#http_lock(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Lock request.
-
#http_mkcol(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Mkcol request.
-
#http_move(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Move request.
-
#http_ok?(options = {}) ⇒ Boolean
protected
Checks if the response has an HTTP OK status code.
-
#http_options(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Options request.
-
#http_post(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Post request.
-
#http_post_body(options = {}) {|response| ... } ⇒ String
protected
Performs an HTTP Post request.
-
#http_powered_by(options = {}) ⇒ String
protected
Sends an HTTP Head request and returns the HTTP X-Powered-By header.
-
#http_prop_find(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Propfind request.
-
#http_prop_patch(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Proppatch request.
-
#http_request(options = {}) {|request, (options)| ... } ⇒ Net::HTTP::Response
protected
Connects to the HTTP server and sends an HTTP Request.
-
#http_server(options = {}) ⇒ String
protected
Sends a HTTP Head request and returns the HTTP Server header.
-
#http_session(options = {}) {|session| ... } ⇒ Net::HTTP
protected
Connects to the HTTP server.
-
#http_status(options = {}) ⇒ Integer
protected
Returns the Status Code of the Response.
-
#http_trace(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Trace request.
-
#http_unlock(options = {}) {|response| ... } ⇒ Net::HTTP::Response
protected
Performs an HTTP Unlock request.
Methods included from Mixin
Instance Method Details
#disable_http_proxy ⇒ Object (protected)
Resets the HTTP proxy settings.
83 84 85 |
# File 'lib/ronin/network/mixins/http.rb', line 83 def disable_http_proxy @http_proxy = nil end |
#http_copy(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Copy request.
303 304 305 306 307 308 |
# File 'lib/ronin/network/mixins/http.rb', line 303 def http_copy(={},&block) = () print_info "HTTP COPY #{()}" return Net.http_copy(,&block) end |
#http_delete(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Delete request.
327 328 329 330 331 332 |
# File 'lib/ronin/network/mixins/http.rb', line 327 def http_delete(={},&block) = () print_info "HTTP DELETE #{()}" return Net.http_delete(,&block) end |
#http_get(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Get request.
351 352 353 354 355 356 |
# File 'lib/ronin/network/mixins/http.rb', line 351 def http_get(={},&block) = () print_info "HTTP GET #{()}" return Net.http_get(,&block) end |
#http_get_body(options = {}) {|response| ... } ⇒ String (protected)
Performs an HTTP Get request.
375 376 377 378 379 380 |
# File 'lib/ronin/network/mixins/http.rb', line 375 def http_get_body(={},&block) = () print_info "HTTP GET #{()}" return Net.http_get_body(,&block) end |
#http_head(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Head request.
399 400 401 402 403 404 |
# File 'lib/ronin/network/mixins/http.rb', line 399 def http_head(={},&block) = () print_info "HTTP HEAD #{()}" return Net.http_head(,&block) end |
#http_lock(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Lock request.
423 424 425 426 427 428 |
# File 'lib/ronin/network/mixins/http.rb', line 423 def http_lock(={},&block) = () print_info "HTTP LOCK #{()}" return Net.http_lock(,&block) end |
#http_mkcol(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Mkcol request.
447 448 449 450 451 452 |
# File 'lib/ronin/network/mixins/http.rb', line 447 def http_mkcol(={},&block) = () print_info "HTTP MKCOL #{()}" return Net.http_mkcol(,&block) end |
#http_move(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Move request.
471 472 473 474 475 476 |
# File 'lib/ronin/network/mixins/http.rb', line 471 def http_move(={},&block) = () print_info "HTTP MOVE #{()}" return Net.http_move(,&block) end |
#http_ok?(options = {}) ⇒ Boolean (protected)
Checks if the response has an HTTP OK status code.
220 221 222 223 224 225 226 227 228 |
# File 'lib/ronin/network/mixins/http.rb', line 220 def http_ok?(={}) = () if (result = Net.http_ok?()) print_debug "HTTP 200 OK #{()}" end return result end |
#http_options(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Options request.
495 496 497 498 499 500 |
# File 'lib/ronin/network/mixins/http.rb', line 495 def (={},&block) = () print_info "HTTP OPTIONS #{()}" return Net.(,&block) end |
#http_post(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Post request.
525 526 527 528 529 530 |
# File 'lib/ronin/network/mixins/http.rb', line 525 def http_post(={},&block) = () print_info "HTTP POST #{()}" return Net.http_post(,&block) end |
#http_post_body(options = {}) {|response| ... } ⇒ String (protected)
Performs an HTTP Post request.
549 550 551 552 553 554 |
# File 'lib/ronin/network/mixins/http.rb', line 549 def http_post_body(={},&block) = () print_info "HTTP POST #{()}" return Net.http_post_body(,&block) end |
#http_powered_by(options = {}) ⇒ String (protected)
Sends an HTTP Head request and returns the HTTP X-Powered-By header.
276 277 278 279 280 281 282 283 284 |
# File 'lib/ronin/network/mixins/http.rb', line 276 def http_powered_by(={}) = () if (result = Net.http_powered_by()) print_debug "HTTP X-Powered-By: #{result}" end return result end |
#http_prop_find(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Propfind request.
573 574 575 576 577 578 |
# File 'lib/ronin/network/mixins/http.rb', line 573 def http_prop_find(={},&block) = () print_info "HTTP PROPFIND #{()}" return Net.http_prop_find(,&block) end |
#http_prop_patch(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Proppatch request.
597 598 599 600 601 602 |
# File 'lib/ronin/network/mixins/http.rb', line 597 def http_prop_patch(={},&block) = () print_info "HTTP PROPPATCH #{()}" return Net.http_prop_patch(,&block) end |
#http_request(options = {}) {|request, (options)| ... } ⇒ Net::HTTP::Response (protected)
Connects to the HTTP server and sends an HTTP Request.
167 168 169 170 171 172 |
# File 'lib/ronin/network/mixins/http.rb', line 167 def http_request(={},&block) = () print_info "HTTP #{[:method]} #{()}" return Net.http_request(,&block) end |
#http_server(options = {}) ⇒ String (protected)
Sends a HTTP Head request and returns the HTTP Server header.
248 249 250 251 252 253 254 255 256 |
# File 'lib/ronin/network/mixins/http.rb', line 248 def http_server(={}) = () if (result = Net.http_server()) print_debug "HTTP Server: #{result}" end return result end |
#http_session(options = {}) {|session| ... } ⇒ Net::HTTP (protected)
Connects to the HTTP server.
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/ronin/network/mixins/http.rb', line 125 def http_session(={}) = () host_port = "#{[:host]}:#{[:port]}" Net.http_session() do |http| print_info "Starting HTTP Session with #{host_port}" yield http print_info "Closing HTTP Session with #{host_port}" end end |
#http_status(options = {}) ⇒ Integer (protected)
Returns the Status Code of the Response.
192 193 194 195 196 197 198 199 200 |
# File 'lib/ronin/network/mixins/http.rb', line 192 def http_status(={}) = () if (result = Net.http_status()) print_debug "HTTP #{result} #{()}" end return result end |
#http_trace(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Trace request.
621 622 623 624 625 626 |
# File 'lib/ronin/network/mixins/http.rb', line 621 def http_trace(={},&block) = () print_info "HTTP TRACE #{()}" return Net.http_trace(,&block) end |
#http_unlock(options = {}) {|response| ... } ⇒ Net::HTTP::Response (protected)
Performs an HTTP Unlock request.
645 646 647 648 649 650 |
# File 'lib/ronin/network/mixins/http.rb', line 645 def http_unlock(={},&block) = () print_info "HTTP UNLOCK #{()}" return Net.http_unlock(,&block) end |