Module: Ronin::Support::Network::HTTP::Mixin

Included in:
Mixin
Defined in:
lib/ronin/support/network/http/mixin.rb

Overview

Provides helper methods for communicating with HTTP Servers.

Instance Method Summary collapse

Instance Method Details

#http_allowed_methods(url, ssl: nil, **kwargs) ⇒ Array<Symbol>

Performs a OPTIONS HTTP request for the given URI and parses the Allow response header.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

  • (Array<Symbol>)

    The allowed HTTP request methods for the given URL.

See Also:



684
685
686
# File 'lib/ronin/support/network/http/mixin.rb', line 684

def http_allowed_methods(url, ssl: nil, **kwargs)
  Network::HTTP.allowed_methods(url, ssl: ssl, **kwargs)
end

#http_connect(host, port, ssl: nil, **kwargs) {|http| ... } ⇒ HTTP?

Creates a HTTP connection to the host nad port.

Parameters:

  • host (String)

    The host to connect to.

  • port (Integer)

    The port to connect to.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (http)

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

Yield Parameters:

  • http (HTTP)

    The HTTP session object.

Returns:

  • (HTTP, nil)

    The HTTP session object. If a block is given, then nil will be returned.

Since:

  • 1.0.0



133
134
135
# File 'lib/ronin/support/network/http/mixin.rb', line 133

def http_connect(host,port, ssl: nil, **kwargs,&block)
  Network::HTTP.connect(host,port, ssl: ssl, **kwargs,&block)
end

#http_connect_uri(url, ssl: nil, **kwargs) {|http| ... } ⇒ HTTP?

Creates a HTTP connection using the URI.

Parameters:

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

    The URI to connect to.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (http)

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

Yield Parameters:

  • http (HTTP)

    The HTTP session object.

Returns:

  • (HTTP, nil)

    The HTTP session object. If a block is given, then nil will be returned.

Since:

  • 1.0.0



161
162
163
# File 'lib/ronin/support/network/http/mixin.rb', line 161

def http_connect_uri(url, ssl: nil, **kwargs,&block)
  Network::HTTP.connect_uri(url, ssl: ssl, **kwargs,&block)
end

#http_copy(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a COPY request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



396
397
398
# File 'lib/ronin/support/network/http/mixin.rb', line 396

def http_copy(url, ssl: nil, **kwargs,&block)
  Network::HTTP.copy(url, ssl: ssl, **kwargs,&block)
end

#http_delete(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a DELETE request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



422
423
424
# File 'lib/ronin/support/network/http/mixin.rb', line 422

def http_delete(url, ssl: nil, **kwargs,&block)
  Network::HTTP.delete(url, ssl: ssl, **kwargs,&block)
end

#http_get(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a GET request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



448
449
450
# File 'lib/ronin/support/network/http/mixin.rb', line 448

def http_get(url, ssl: nil, **kwargs,&block)
  Network::HTTP.get(url, ssl: ssl, **kwargs,&block)
end

#http_get_body(url, ssl: nil, **kwargs) ⇒ String

Performs a GET request for the given URI and returns the response body.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

  • (String)

    The response body.

See Also:



533
534
535
# File 'lib/ronin/support/network/http/mixin.rb', line 533

def http_get_body(url, ssl: nil, **kwargs)
  Network::HTTP.get_body(url, ssl: ssl, **kwargs)
end

#http_get_cookies(url, ssl: nil, **kwargs) ⇒ Array<SetCookie>?

Sends an HTTP request and returns the parsed Set-Cookie header(s).

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

See Also:



492
493
494
# File 'lib/ronin/support/network/http/mixin.rb', line 492

def http_get_cookies(url, ssl: nil, **kwargs)
  Network::HTTP.get_cookies(url, ssl: ssl, **kwargs)
end

#http_get_headers(url, ssl: nil, **kwargs) ⇒ Hash{String => String}

Performs a GET request for the given URI and returns the response headers.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

See Also:

Since:

  • 0.2.0



471
472
473
# File 'lib/ronin/support/network/http/mixin.rb', line 471

def http_get_headers(url, ssl: nil, **kwargs)
  Network::HTTP.get_headers(url, ssl: ssl, **kwargs)
end

#http_head(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a HEAD request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



559
560
561
# File 'lib/ronin/support/network/http/mixin.rb', line 559

def http_head(url, ssl: nil, **kwargs,&block)
  Network::HTTP.head(url, ssl: ssl, **kwargs,&block)
end

#http_lock(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a LOCK request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



585
586
587
# File 'lib/ronin/support/network/http/mixin.rb', line 585

def http_lock(url, ssl: nil, **kwargs,&block)
  Network::HTTP.lock(url, ssl: ssl, **kwargs,&block)
end

#http_mkcol(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a MKCOL request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



611
612
613
# File 'lib/ronin/support/network/http/mixin.rb', line 611

def http_mkcol(url, ssl: nil, **kwargs,&block)
  Network::HTTP.mkcol(url, ssl: ssl, **kwargs,&block)
end

#http_move(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a MOVE request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



637
638
639
# File 'lib/ronin/support/network/http/mixin.rb', line 637

def http_move(url, ssl: nil, **kwargs,&block)
  Network::HTTP.move(url, ssl: ssl, **kwargs,&block)
end

#http_ok?(method = :head, url, ssl: nil, **kwargs) ⇒ Boolean

Sends a HTTP request and determines if the response status was 200.

Parameters:

  • method (Symbol, String) (defaults to: :head)

    The HTTP method to use for the request.

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

  • (Boolean)

    Indicates that the response status was 200.

See Also:



276
277
278
# File 'lib/ronin/support/network/http/mixin.rb', line 276

def http_ok?(method=:head,url, ssl: nil, **kwargs)
  Network::HTTP.ok?(method,url, ssl: ssl, **kwargs)
end

#http_options(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a OPTIONS request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



663
664
665
# File 'lib/ronin/support/network/http/mixin.rb', line 663

def http_options(url, ssl: nil, **kwargs,&block)
  Network::HTTP.options(url, ssl: ssl, **kwargs,&block)
end

#http_patch(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a PATCH request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:

Since:

  • 1.0.0



712
713
714
# File 'lib/ronin/support/network/http/mixin.rb', line 712

def http_patch(url, ssl: nil, **kwargs,&block)
  Network::HTTP.patch(url, ssl: ssl, **kwargs,&block)
end

#http_post(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a POST request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



738
739
740
# File 'lib/ronin/support/network/http/mixin.rb', line 738

def http_post(url, ssl: nil, **kwargs,&block)
  Network::HTTP.post(url, ssl: ssl, **kwargs,&block)
end

#http_post_body(url, ssl: nil, **kwargs) ⇒ String

Performs a POST request for the given URI and returns the response body.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

  • (String)

    The response body.

See Also:



782
783
784
# File 'lib/ronin/support/network/http/mixin.rb', line 782

def http_post_body(url, ssl: nil, **kwargs)
  Network::HTTP.post_body(url, ssl: ssl, **kwargs)
end

#http_post_cookies(url, ssl: nil, **kwargs) ⇒ Array<SetCookie>?

Sends an HTTP request and returns the parsed Set-Cookie header(s).

Parameters:

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

    Optional URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

See Also:



512
513
514
# File 'lib/ronin/support/network/http/mixin.rb', line 512

def http_post_cookies(url, ssl: nil, **kwargs)
  Network::HTTP.post_cookies(url, ssl: ssl, **kwargs)
end

#http_post_headers(url, ssl: nil, **kwargs) ⇒ Hash{String => String}

Performs a POST request on the given URI and returns the response headers.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

See Also:

Since:

  • 0.2.0



761
762
763
# File 'lib/ronin/support/network/http/mixin.rb', line 761

def http_post_headers(url, ssl: nil, **kwargs)
  Network::HTTP.post_headers(url, ssl: ssl, **kwargs)
end

#http_powered_by_header(url, ssl: nil, **kwargs) ⇒ String?

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

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

  • (String, nil)

    The X-Powered-By header.

See Also:

Since:

  • 1.0.0



345
346
347
# File 'lib/ronin/support/network/http/mixin.rb', line 345

def http_powered_by_header(url, ssl: nil, **kwargs)
  Network::HTTP.powered_by_header(url, ssl: ssl, **kwargs)
end

#http_propfind(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse Also known as: http_prop_find

Performs a PROPFIND request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



808
809
810
# File 'lib/ronin/support/network/http/mixin.rb', line 808

def http_propfind(url, ssl: nil, **kwargs,&block)
  Network::HTTP.propfind(url, ssl: ssl, **kwargs,&block)
end

#http_proppatch(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse Also known as: http_prop_patch

Performs a PROPPATCH request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



836
837
838
# File 'lib/ronin/support/network/http/mixin.rb', line 836

def http_proppatch(url, ssl: nil, **kwargs,&block)
  Network::HTTP.proppatch(url, ssl: ssl, **kwargs,&block)
end

#http_put(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a PUT request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:

Since:

  • 0.4.0



866
867
868
# File 'lib/ronin/support/network/http/mixin.rb', line 866

def http_put(url, ssl: nil, **kwargs,&block)
  Network::HTTP.put(url, ssl: ssl, **kwargs,&block)
end

#http_request(method, url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs and arbitrary HTTP request.

Parameters:

  • method (Symbol, String)

    The HTTP method to use for the request.

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

Raises:

  • (ArgumentError)

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

See Also:



228
229
230
# File 'lib/ronin/support/network/http/mixin.rb', line 228

def http_request(method,url, ssl: nil, **kwargs,&block)
  Network::HTTP.request(method,url, ssl: ssl, **kwargs,&block)
end

#http_response_body(method = :get, url, ssl: nil, **kwargs) ⇒ String

Sends an arbitrary HTTP request and returns the response body.

Parameters:

  • method (Symbol, String) (defaults to: :get)

    The HTTP method to use for the request.

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

  • (String)

    The response body.

See Also:

Since:

  • 1.0.0



370
371
372
# File 'lib/ronin/support/network/http/mixin.rb', line 370

def http_response_body(method=:get,url, ssl: nil, **kwargs)
  Network::HTTP.response_body(method,url, ssl: ssl, **kwargs)
end

#http_response_headers(method = :head, url, ssl: nil, **kwargs) ⇒ Hash{String => String}

Sends an arbitrary HTTP request and returns the response headers.

Parameters:

  • method (Symbol, String) (defaults to: :head)

    The HTTP method to use for the request.

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

See Also:

Since:

  • 1.0.0



301
302
303
# File 'lib/ronin/support/network/http/mixin.rb', line 301

def http_response_headers(method=:head,url, ssl: nil, **kwargs)
  Network::HTTP.response_headers(method,url, ssl: ssl, **kwargs)
end

#http_response_status(method = :head, url, ssl: nil, **kwargs) ⇒ Integer

Sends an arbitrary HTTP request and returns the response status.

Parameters:

  • method (Symbol, String) (defaults to: :head)

    The HTTP method to use for the request.

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Returns:

  • (Integer)

    The status code of the response.

See Also:

Since:

  • 1.0.0



253
254
255
# File 'lib/ronin/support/network/http/mixin.rb', line 253

def http_response_status(method=:head,url, ssl: nil, **kwargs)
  Network::HTTP.response_status(method,url, ssl: ssl, **kwargs)
end

#http_server_header(url, ssl: nil, **kwargs) ⇒ String?

Sends an HTTP request and returns the Server header.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

Returns:

  • (String, nil)

    The Server header.

See Also:

Since:

  • 1.0.0



323
324
325
# File 'lib/ronin/support/network/http/mixin.rb', line 323

def http_server_header(url, ssl: nil, **kwargs)
  Network::HTTP.server_header(url, ssl: ssl, **kwargs)
end

#http_trace(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a TRACE request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



892
893
894
# File 'lib/ronin/support/network/http/mixin.rb', line 892

def http_trace(url, ssl: nil, **kwargs,&block)
  Network::HTTP.trace(url, ssl: ssl, **kwargs,&block)
end

#http_unlock(url, ssl: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse

Performs a UNLOCK request for the given URI.

Parameters:

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

    The URL to create the HTTP request for.

  • ssl (Boolean, Hash{Symbol => Object}, nil) (defaults to: nil)

    Specifies whether to enable SSL and/or the SSL context configuration.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Options Hash (ssl:):

  • :ca_bundle (String, nil)

    The path to the CA bundle directory or file.

  • :cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The certificate to use for the SSL/TLS connection.

  • :cert_store (OpenSSL::X509::Store, nil)

    The certificate store to use for the SSL/TLS connection.

  • :ciphers (Array<(name, version, bits, alg_bits)>, nil)

    The accepted ciphers to use for the SSL/TLS connection.

  • :extra_chain_cert (Crypto::Cert, OpenSSL::X509::Certificate, nil)

    The extra certificate to add to the SSL/TLS certificate chain.

  • :key (Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil)

    The RSA or DSA key to use for the SSL/TLS connection.

  • :timeout (Integer, nil)

    The connection timeout limit.

  • :version (1, 1.1, 1.2, Symbol, nil)

    The desired SSL/TLS version.

  • :min_version (1, 1.1, 1.2, Symbol, nil)

    The minimum SSL/TLS version.

  • :max_version (1, 1.1, 1.2, Symbol, nil)

    The maximum SSL/TLS version.

  • :verify_callback (Proc, nil)

    The callback to use when verifying the server's certificate.

  • :verify_depth (Integer, nil)

    The verification depth limit.

  • :verify (:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil)

    The verification mode.

  • :verify_hostname (Boolean, nil)

    Indicates whether to verify the server's hostname.

Options Hash (**kwargs):

  • :query (String, nil)

    The query-string to append to the request path.

  • :query_params (Hash, nil)

    The query-params to append to the request path.

  • :user (String, nil)

    The user to authenticate as.

  • :password (String, nil)

    The password to authenticate with.

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

    Additional HTTP headers to use for the request.

  • :cookie (String, Hash{String => String}, Cookie, nil)

    Additional Cookie header. If a Hash is given, it will be converted to a String using Cookie. If the cookie value is empty, the Cookie header will not be set.

  • :body (String, nil)

    The body of the request.

  • :form_data (Hash, String, nil)

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

  • :json (#to_json, nil)

    The JSON data that will be sent in the body of the request. Will also default the Content-Type header to application/json, unless already set.

  • :proxy (String, URI::HTTP, Addressable::URI, nil)

    The optional proxy to send requests through.

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

    Additional headers to add to each request.

  • :content_type (String, :text, :xml, :html, :json, nil)

    The Content-Type header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • :accept (String, :text, :xml, :html, :json, nil)

    The Accept header value for the request. If a Symbol is given it will be resolved to a common MIME type:

    • :text - text/plain
    • :xml - text/xml
    • :html - text/html
    • :json - application/json
  • user_agent (String, :random, :chrome, :chrome_linux, :chrome_macos, :chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android, nil) — default: HTTP.user_agent

    The default User-Agent string to add to each request.

Yields:

  • (response)

    If a block is given it will be passed the received HTTP response.

Yield Parameters:

  • response (Net::HTTPRresponse)

    The received HTTP response object.

Returns:

  • (Net::HTTPResponse)

    The new HTTP Request object.

See Also:



918
919
920
# File 'lib/ronin/support/network/http/mixin.rb', line 918

def http_unlock(url, ssl: nil, **kwargs,&block)
  Network::HTTP.unlock(url, ssl: ssl, **kwargs,&block)
end