Module: Ronin::Network::HTTP

Included in:
Net, Mixins::HTTP, Support, URI::HTTP
Defined in:
lib/ronin/network/http/http.rb,
lib/ronin/network/http/proxy.rb,
lib/ronin/network/http/exceptions/unknown_request.rb

Overview

Provides helper methods for communicating with HTTP Servers.

Defined Under Namespace

Classes: Proxy, UnknownRequest

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Hash) expand_options(options = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Expands the given HTTP options.

Parameters:

  • options (Hash) (defaults to: {})

    HTTP options.

Options Hash (options):

  • :url (String, URI::HTTP, URI::HTTPS)

    The URL to request.

  • :host (String)

    The host to connect to.

  • :port (String) — default: Net::HTTP.default_port

    The port to connect to.

  • :user (String)

    The user to authenticate as.

  • :password (String)

    The password to authenticate with.

  • :path (String) — default: '/'

    The path to request.

  • :proxy (String, Hash) — default: HTTP.proxy

    The Proxy information.

Returns:

  • (Hash)

    The expanded version of options.



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/ronin/network/http/http.rb', line 178

def self.expand_options(options={})
  new_options = options.dup

  new_options[:port] ||= Net::HTTP.default_port
  new_options[:path] ||= '/'

  if new_options[:ssl] == true
    new_options[:ssl] = {}
  end

  if (url = new_options.delete(:url))
    new_options.merge!(HTTP.expand_url(url))
  end

  new_options[:proxy] = if new_options.has_key?(:proxy)
                          HTTP::Proxy.create(new_options[:proxy])
                        else
                          HTTP.proxy
                        end

  return new_options
end

+ (Hash{Symbol => Object}) expand_url(url)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Expands the URL into options.

Parameters:

Returns:

  • (Hash{Symbol => Object})

    The options for the URL.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/ronin/network/http/http.rb', line 116

def self.expand_url(url)
  new_options = {}

  url = case url
        when URI
          url
        when Hash
          URI::HTTP.build(url)
        else
          URI(url.to_s)
        end

  new_options[:ssl] = {} if url.scheme == 'https'

  new_options[:host] = url.host
  new_options[:port] = url.port

  new_options[:user]     = url.user     if url.user
  new_options[:password] = url.password if url.password

  new_options[:path] = unless url.path.empty?
                         url.path
                       else
                         '/'
                       end
  new_options[:path] += "?#{url.query}" if url.query

  return new_options
end

+ (String) header_name(name)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts an underscored, dashed, lowercase or uppercase HTTP header name to the standard camel-case HTTP header name.

Parameters:

  • name (Symbol, String)

    The unformatted HTTP header name.

Returns:

  • (String)

    The camel-case HTTP header name.



213
214
215
216
217
218
# File 'lib/ronin/network/http/http.rb', line 213

def self.header_name(name)
  words = name.to_s.split(/[\s+_-]/)

  words.each { |word| word.capitalize! }
  return words.join('-')
end

+ (Hash) headers(options = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts underscored, dashed, lowercase and uppercase HTTP headers to standard camel-cased HTTP headers.

Parameters:

  • options (Hash{Symbol,String => String}) (defaults to: {})

    Ronin HTTP headers.

Returns:

  • (Hash)

    The camel-cased HTTP headers created from the given options.



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/ronin/network/http/http.rb', line 232

def self.headers(options={})
  headers = {}

  if user_agent
    headers['User-Agent'] = user_agent
  end

  if options
    options.each do |name,value|
      headers[HTTP.header_name(name)] = value.to_s
    end
  end

  return headers
end

+ (Proxy) proxy

Note:

If the HTTP_PROXY environment variable is specified, it will be used as the default value.

The Ronin HTTP proxy to use.

Returns:

  • (Proxy)

    The Ronin HTTP proxy.

See Also:



54
55
56
57
58
59
60
# File 'lib/ronin/network/http/http.rb', line 54

def self.proxy
  @proxy ||= if ENV['HTTP_PROXY']
               Proxy.parse(ENV['HTTP_PROXY'])
             else
               Proxy.new
             end
end

+ (Proxy) proxy=(new_proxy)

Sets the Ronin HTTP proxy to use.

Parameters:

Returns:

  • (Proxy)

    The new proxy.

Raises:

  • (ArgumentError)

    The given proxy information was not a Proxy, URI::HTTP, Hash or String.



77
78
79
# File 'lib/ronin/network/http/http.rb', line 77

def self.proxy=(new_proxy)
  @proxy = Proxy.create(new_proxy)
end

+ (HTTP::Request) request(options = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a specific type of HTTP request object.

Parameters:

  • options (Hash) (defaults to: {})

    The HTTP options for the request.

Options Hash (options):

  • :method (Symbol, String)

    The HTTP method to use for the request.

  • :path (String) — default: '/'

    The path to request.

  • :query (String)

    The query-string to append to the request path.

  • :query_params (String)

    The query-params to append to the request path.

  • :body (String)

    The body of the request.

  • :form_data (Hash, String)

    The form data that may be sent in the body of the request.

  • :user (String)

    The user to authenticate as.

  • :password (String)

    The password to authenticate with.

  • :headers (Hash{Symbol,String => String})

    Additional HTTP headers to use for the request.

Returns:

  • (HTTP::Request)

    The new HTTP Request object.

Raises:

  • (ArgumentError)

    The :method option must be specified.

  • (UnknownRequest)

    The :method option did not match a known Net::HTTP request class.

See Also:



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/ronin/network/http/http.rb', line 295

def self.request(options={})
  unless options[:method]
    raise(ArgumentError,"the :method option must be specified")
  end

  name = options[:method].to_s.capitalize

  unless Net::HTTP.const_defined?(name)
    raise(UnknownRequest,"unknown HTTP request type #{name.dump}")
  end

  headers = headers(options[:headers])
  path    = (options[:path] || '/').to_s
  query   = if options[:query]
              URI.escape(options[:query])
            elsif options[:query_params]
              URI::QueryParams.dump(options[:query_params])
            end

  if query
    # append the query-string onto the path
    path += if path.include?('?')
              "&#{query}"
            else
              "?#{query}"
            end
  end

  request = Net::HTTP.const_get(name).new(path,headers)

  if request.request_body_permitted?
    if options[:form_data]
      request.set_form_data(options[:form_data])
    elsif options[:body]
      request.body = options[:body]
    end
  end

  if options[:user]
    user     = options[:user].to_s
    password = if options[:password]
                 options[:password].to_s
               end

    request.basic_auth(user,password)
  end

  return request
end

+ (String?) user_agent

The default Ronin HTTP User-Agent string.

Returns:

  • (String, nil)

    The default Ronin HTTP User-Agent.



89
90
91
# File 'lib/ronin/network/http/http.rb', line 89

def self.user_agent
  @user_agent ||= nil
end

+ (Object) user_agent=(agent)

Sets the default Ronin HTTP User-Agent string.

Parameters:

  • agent (String)

    The new User-Agent string to use.



101
102
103
# File 'lib/ronin/network/http/http.rb', line 101

def self.user_agent=(agent)
  @user_agent = agent
end

Instance Method Details

- (Net::HTTP) http_connect(options = {}) {|http| ... }

Starts a HTTP connection with the server.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options

  • :ssl (Hash)

    a customizable set of options

Options Hash (options):

  • :url (String, URI::HTTP)

    The full URL to request.

  • :host (String)

    The host the HTTP server is running on.

  • :port (Integer) — default: Net::HTTP.default_port

    The port the HTTP server is listening on.

  • :proxy (String, Hash) — default: HTTP.proxy

    A Hash of proxy settings to use when connecting to the HTTP server.

  • :user (String)

    The user to authenticate with when connecting to the HTTP server.

  • :password (String)

    The password to authenticate with when connecting to the HTTP server.

  • :ssl (Boolean, Hash)

    Enables SSL for the HTTP connection.

Yields:

  • (http)

    If a block is given, it will be passed the newly created HTTP session object.

Yield Parameters:

  • http (Net::HTTP)

    The newly created HTTP session.

Returns:

  • (Net::HTTP)

    The HTTP session object.



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/ronin/network/http/http.rb', line 387

def http_connect(options={},&block)
  options = HTTP.expand_options(options)

  host  = options[:host].to_s
  port  = options[:port]
  proxy = options[:proxy]
  proxy_host = if (proxy && proxy[:host])
                 proxy[:host].to_s
               end

  http = Net::HTTP::Proxy(
    proxy_host,
    proxy[:port],
    proxy[:user],
    proxy[:password]
  ).new(host,port)

  if options[:ssl]
    http.use_ssl     = true
    http.verify_mode = SSL::VERIFY[options[:ssl][:verify]]
  end

  http.start()

  if block
    if block.arity == 2
      block.call(http,options)
    else
      block.call(http)
    end
  end

  return http
end

- (Net::HTTP::Response) http_copy(options = {}) {|response| ... }

Performs an HTTP Copy request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



649
650
651
652
653
654
# File 'lib/ronin/network/http/http.rb', line 649

def http_copy(options={})
  response = http_request(options.merge(:method => :copy))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_delete(options = {}) {|response| ... }

Performs an HTTP Delete request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/ronin/network/http/http.rb', line 676

def http_delete(options={},&block)
  original_headers = options[:headers]

  # set the HTTP Depth header
  options[:headers] = {:depth => 'Infinity'}

  if original_headers
    options[:header].merge!(original_headers)
  end

  response = http_request(options.merge(:method => :delete))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_get(options = {}) {|response| ... }

Performs an HTTP Get request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



712
713
714
715
716
717
# File 'lib/ronin/network/http/http.rb', line 712

def http_get(options={},&block)
  response = http_request(options.merge(:method => :get))

  yield response if block_given?
  return response
end

- (String) http_get_body(options = {})

Performs an HTTP Get request and returns the Respond Body.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Returns:

  • (String)

    The body of the HTTP response.

See Also:



757
758
759
# File 'lib/ronin/network/http/http.rb', line 757

def http_get_body(options={})
  http_get(options).body
end

- (Hash{String => Array<String>}) http_get_headers(options = {})

Performs an HTTP Get request and returns the Response Headers.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Returns:

See Also:

Since:

  • 0.2.0



734
735
736
737
738
739
740
741
742
# File 'lib/ronin/network/http/http.rb', line 734

def http_get_headers(options={})
  headers = {}

  http_get(options).each_header do |name,value|
    headers[HTTP.header_name(name)] = value
  end

  return headers
end

- (Net::HTTP::Response) http_head(options = {}) {|response| ... }

Performs an HTTP Head request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



781
782
783
784
785
786
# File 'lib/ronin/network/http/http.rb', line 781

def http_head(options={},&block)
  response = http_request(options.merge(:method => :head))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_lock(options = {}) {|response| ... }

Performs an HTTP Lock request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



808
809
810
811
812
813
# File 'lib/ronin/network/http/http.rb', line 808

def http_lock(options={},&block)
  response = http_request(options.merge(:method => :lock))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_mkcol(options = {}) {|response| ... }

Performs an HTTP Mkcol request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



835
836
837
838
839
840
# File 'lib/ronin/network/http/http.rb', line 835

def http_mkcol(options={},&block)
  response = http_request(options.merge(:method => :mkcol))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_move(options = {}) {|response| ... }

Performs an HTTP Move request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



862
863
864
865
866
867
# File 'lib/ronin/network/http/http.rb', line 862

def http_move(options={},&block)
  response = http_request(options.merge(:method => :move))

  yield response if block_given?
  return response
end

- (Boolean) http_ok?(options = {})

Checks if the response has an HTTP OK status code.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :method (Symbol, String) — default: :head

    The method to use for the request.

Returns:

  • (Boolean)

    Specifies whether the response had an HTTP OK status code or not.

See Also:



581
582
583
# File 'lib/ronin/network/http/http.rb', line 581

def http_ok?(options={})
  http_status(options) == 200
end

- (Net::HTTP::Response) http_options(options = {}) {|response| ... }

Performs an HTTP Options request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



889
890
891
892
893
894
# File 'lib/ronin/network/http/http.rb', line 889

def http_options(options={},&block)
  response = http_request(options.merge(:method => :options))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_post(options = {}) {|response| ... }

Performs an HTTP Post request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :form_data (Hash, String)

    The form data to send with the HTTP Post request.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



919
920
921
922
923
924
# File 'lib/ronin/network/http/http.rb', line 919

def http_post(options={},&block)
  response = http_request(options.merge(:method => :post))

  yield response if block_given?
  return response
end

- (String) http_post_body(options = {})

Performs an HTTP Post request and returns the Response Body.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :form_data (Hash, String)

    The form data to send with the HTTP Post request.

Returns:

  • (String)

    The body of the HTTP response.

See Also:



970
971
972
# File 'lib/ronin/network/http/http.rb', line 970

def http_post_body(options={})
  http_post(options).body
end

- (Hash{String => Array<String>}) http_post_headers(options = {})

Performs an HTTP Post request and returns the Response Headers.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :form_data (Hash, String)

    The form data to send with the HTTP Post request.

Returns:

See Also:

Since:

  • 0.2.0



944
945
946
947
948
949
950
951
952
# File 'lib/ronin/network/http/http.rb', line 944

def http_post_headers(options={})
  headers = {}

  http_post(options).each_header do |name,value|
    headers[HTTP.header_name(name)] = value
  end

  return headers
end

- (String) http_powered_by(options = {})

Sends an HTTP Head request and returns the HTTP X-Powered-By header.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :method (Symbol, String) — default: :get

    The method to use for the request.

Returns:

  • (String)

    The HTTP X-Powered-By header.

See Also:



623
624
625
626
627
# File 'lib/ronin/network/http/http.rb', line 623

def http_powered_by(options={})
  options = {:method => :get}.merge(options)

  return http_request(options)['x-powered-by']
end

- (Net::HTTP::Response) http_prop_find(options = {}) {|response| ... }

Performs an HTTP Propfind request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
# File 'lib/ronin/network/http/http.rb', line 1029

def http_prop_find(options={},&block)
  original_headers = options[:headers]

  # set the HTTP Depth header
  options[:headers] = {:depth => '0'}

  if original_headers
    options[:header].merge!(original_headers)
  end

  response = http_request(options.merge(:method => :propfind))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_prop_patch(options = {}) {|response| ... }

Performs an HTTP Proppatch request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



1065
1066
1067
1068
1069
1070
# File 'lib/ronin/network/http/http.rb', line 1065

def http_prop_patch(options={},&block)
  response = http_request(options.merge(:method => :proppatch))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_put(options = {}) {|response| ... }

Performs an HTTP PUT request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :body (String)

    The body for the request.

  • :form_data (Hash, String)

    The form data to send with the HTTP PUT request.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:

Since:

  • 0.4.0



1002
1003
1004
1005
1006
1007
# File 'lib/ronin/network/http/http.rb', line 1002

def http_put(options={})
  response = http_request(options.merge(:method => :put))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_request(options = {}) {|request, (options)| ... }

Connects to the HTTP server and sends an HTTP Request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :method (Symbol, String)

    The HTTP method to use in the request.

  • :path (String)

    The path to request from the HTTP server.

  • :headers (Hash)

    The Hash of the HTTP headers to send with the request. May contain either Strings or Symbols, lower-case or camel-case keys.

  • :body (String)

    The body of the request.

  • :form_data (Hash, String)

    The form data that may be sent in the body of the request.

Yields:

  • (request, (options))

    If a block is given, it will be passed the HTTP request object. If the block has an arity of 2, it will also be passed the expanded version of the given options.

Yield Parameters:

  • request (Net::HTTP::Request)

    The HTTP request object to use in the request.

  • options (Hash)

    The expanded version of the given options.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/ronin/network/http/http.rb', line 521

def http_request(options={},&block)
  response = nil

  http_session(options) do |http,expanded_options|
    req = HTTP.request(expanded_options)

    if block
      if block.arity == 2
        block.call(req,expanded_options)
      else
        block.call(req)
      end
    end

    response = http.request(req)
  end

  return response
end

- (String) http_server(options = {})

Sends a HTTP Head request and returns the HTTP Server header.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :method (Symbol, String) — default: :head

    The method to use for the request.

Returns:

  • (String)

    The HTTP Server header.

See Also:



601
602
603
604
605
# File 'lib/ronin/network/http/http.rb', line 601

def http_server(options={})
  options = {:method => :head}.merge(options)

  return http_request(options)['server']
end

- (nil) http_session(options = {}) {|http| ... }

Creates a new temporary HTTP session with the server.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options

  • :ssl (Hash)

    a customizable set of options

Options Hash (options):

  • :url (String, URI::HTTP)

    The full URL to request.

  • :host (String)

    The host the HTTP server is running on.

  • :port (Integer) — default: Net::HTTP.default_port

    The port the HTTP server is listening on.

  • :user (String)

    The user to authenticate with when connecting to the HTTP server.

  • :password (String)

    The password to authenticate with when connecting to the HTTP server.

  • :proxy (String, Hash) — default: HTTP.proxy

    A Hash of proxy settings to use when connecting to the HTTP server.

  • :ssl (Boolean, Hash)

    Enables SSL for the HTTP connection.

Yields:

  • (http)

    If a block is given, it will be passed the newly created HTTP session object.

Yield Parameters:

  • http (Net::HTTP)

    The newly created HTTP session.

Returns:

  • (nil)

See Also:



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/ronin/network/http/http.rb', line 465

def http_session(options={},&block)
  http_connect(options) do |http,expanded_options|
    if block
      if block.arity == 2
        block.call(http,expanded_options)
      else
        block.call(http)
      end
    end

    http.finish
  end

  return nil
end

- (Integer) http_status(options = {})

Returns the Status Code of the Response.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :method (Symbol, String) — default: :head

    The method to use for the request.

Returns:

  • (Integer)

    The HTTP Response Status.

See Also:

Since:

  • 0.2.0



559
560
561
562
563
# File 'lib/ronin/network/http/http.rb', line 559

def http_status(options={})
  options = {:method => :head}.merge(options)

  return http_request(options).code.to_i
end

- (Net::HTTP::Response) http_trace(options = {}) {|response| ... }

Performs an HTTP Trace request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



1092
1093
1094
1095
1096
1097
# File 'lib/ronin/network/http/http.rb', line 1092

def http_trace(options={},&block)
  response = http_request(options.merge(:method => :trace))

  yield response if block_given?
  return response
end

- (Net::HTTP::Response) http_unlock(options = {}) {|response| ... }

Performs an HTTP Unlock request.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (response)

    If a block is given, it will be passed the response received from the request.

Yield Parameters:

  • response (Net::HTTP::Response)

    The HTTP response object.

Returns:

  • (Net::HTTP::Response)

    The response of the HTTP request.

See Also:



1119
1120
1121
1122
1123
1124
# File 'lib/ronin/network/http/http.rb', line 1119

def http_unlock(options={},&block)
  response = http_request(options.merge(:method => :unlock))

  yield response if block_given?
  return response
end