Class: Ronin::Support::Network::HTTP
- Inherits:
-
Object
- Object
- Ronin::Support::Network::HTTP
- Defined in:
- lib/ronin/support/network/http.rb,
lib/ronin/support/network/http/mixin.rb,
lib/ronin/support/network/http/cookie.rb,
lib/ronin/support/network/http/request.rb,
lib/ronin/support/network/http/set_cookie.rb,
lib/ronin/support/network/http/user_agents.rb
Overview
Provides helper methods for communicating with HTTP Servers.
Core-Ext Methods
Defined Under Namespace
Modules: Mixin, Request, UserAgents Classes: Cookie, SetCookie
Instance Attribute Summary collapse
-
#cookie ⇒ Cookie?
The default cookie params to add to every request.
-
#headers ⇒ Hash{String => String,Array}
readonly
Additional headers to add to every request.
-
#host ⇒ String
readonly
The host to connect to.
-
#password ⇒ String?
readonly
The HTTP Baic-Auth password to add to every request.
-
#port ⇒ Integer
readonly
The port to connect to.
-
#proxy ⇒ URI::HTTP, ...
readonly
The proxy to send requests through.
-
#user ⇒ String?
readonly
The HTTP Baic-Auth user to add to every request.
-
#user_agent ⇒ String?
The
User-Agent
header value.
Class Method Summary collapse
-
.allowed_methods(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Array<Symbol>
Performs a
OPTIONS
HTTP request for the given URI and parses theAllow
response header. -
.connect(host, port, ssl: port == 443, **kwargs) {|http| ... } ⇒ HTTP?
Creates a HTTP connection to the host nad port.
-
.connect_uri(url, ssl: nil, user: nil, password: nil, **kwargs) {|http| ... } ⇒ HTTP?
Creates a HTTP connection using the URI.
-
.copy(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
COPY
request for the given URI. -
.delete(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
DELETE
request for the given URI. -
.get(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
GET
request for the given URI. -
.get_body(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String
Performs a
GET
request for the given URI and returns the response body. -
.get_cookies(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Array<SetCookie>?
Sends an HTTP request and returns the parsed
Set-Cookie
header(s). -
.get_headers(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Hash{String => String}
Performs a
GET
request for the given URI and returns the response headers. -
.head(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
HEAD
request for the given URI. -
.lock(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
LOCK
request for the given URI. -
.mkcol(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
MKCOL
request for the given URI. -
.move(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
MOVE
request for the given URI. -
.ok?(method = :head, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Boolean
Sends a HTTP request and determines if the response status was 200.
-
.options(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
OPTIONS
request for the given URI. -
.patch(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
PATCH
request for the given URI. -
.post(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
POST
request for the given URI. -
.post_body(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String
Performs a
POST
request for the given URI and returns the response body. -
.post_headers(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Hash{String => String}
Performs a
POST
request on the given URI and returns the response headers. -
.powered_by_header(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String?
Sends an HTTP request and returns the
X-Powered-By
header. -
.propfind(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
PROPFIND
request for the given URI. -
.proppatch(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
PROPPATCH
request for the given URI. -
.proxy ⇒ URI::HTTP, ...
The Ronin HTTP proxy to use.
-
.proxy=(new_proxy) ⇒ URI::HTTP, ...
Sets the Ronin HTTP proxy to use.
-
.put(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
PUT
request for the given URI. -
.request(method, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs and arbitrary HTTP request.
-
.response_body(method = :get, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String
Sends an arbitrary HTTP request and returns the response body.
-
.response_headers(method = :head, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Hash{String => String}
Sends an arbitrary HTTP request and returns the response headers.
-
.response_status(method = :head, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Integer
Sends an arbitrary HTTP request and returns the response status.
-
.server_header(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String?
Sends an HTTP request and returns the
Server
header. -
.trace(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
TRACE
request for the given URI. -
.unlock(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
UNLOCK
request for the given URI. -
.user_agent ⇒ String?
The default Ronin HTTP
User-Agent
string. -
.user_agent=(new_user_agent) ⇒ String?
Sets the default Ronin HTTP
User-Agent
string.
Instance Method Summary collapse
-
#allowed_methods(path = '*', **kwargs) ⇒ Array<Symbol>
Sends a
OPTIONS
HTTP request and parses theAllow
response header. -
#close ⇒ Object
Closes the HTTP connection.
-
#copy(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
COPY
HTTP request. -
#delete(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
DELETE
HTTP request. -
#get(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
GET
HTTP request. -
#get_body(path, **kwargs) ⇒ String
Sends a
GET
HTTP request and returns the response body. -
#get_cookies(path, **kwargs) ⇒ Array<SetCookie>
Sends an HTTP request and returns the parsed
Set-Cookie
header(s). -
#get_headers(path, **kwargs) ⇒ Hash{String => String}
Sends a
GET
HTTP request and returns the response headers. -
#head(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
HEAD
HTTP request. -
#initialize(host, port, proxy: nil, ssl: port == 443, headers: {}, user_agent: self.class.user_agent, cookie: nil, user: nil, password: nil) {|_self| ... } ⇒ HTTP
constructor
Initializes an HTTP connection.
-
#lock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
LOCK
HTTP request. -
#mkcol(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
MKCOL
HTTP request. -
#move(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
MOVE
HTTP request. -
#ok?(method = :head, path, **kwargs) ⇒ Boolean
Sends a HTTP request and determines if the response status was 200.
-
#options(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
OPTIONS
HTTP request. -
#patch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
PATCH
HTTP request. -
#post(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
POST
HTTP request. -
#post_body(path, **kwargs) ⇒ String
Sends a
POST
HTTP request and returns the response body. -
#post_headers(path, **kwargs) ⇒ Hash{String => String}
Sends a
POST
HTTP request and returns the response headers. -
#powered_by_header(method: :head, path: '/', **kwargs) ⇒ String?
Sends an HTTP request and returns the
X-Powered-By
header. -
#prop_find {|response| ... } ⇒ Net::HTTPResponse
Sends a
PROPFIND
HTTP request. -
#prop_patch {|response| ... } ⇒ Net::HTTPResponse
Sends a
PROPPATCH
HTTP request. -
#propfind(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
PROPFIND
HTTP request. -
#proppatch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
PROPPATCH
HTTP request. -
#put(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
PUT
HTTP request. -
#request(method, path, query: nil, query_params: nil, headers: nil, user_agent: @user_agent, cookie: @cookie, user: @user, password: @password, body: nil, form_data: nil, **additional_headers) {|response| ... } ⇒ Net::HTTPResponse
Sends an arbitrary HTTP request.
-
#response_body(method = :get, path, **kwargs) ⇒ String
Sends an arbitrary HTTP request and returns the response body.
-
#response_headers(method = :head, path, **kwargs) ⇒ Hash{String => String}
Sends an arbitrary HTTP request and returns the response headers.
-
#response_status(method = :head, path, **kwargs) ⇒ Integer
Sends an arbitrary HTTP request and returns the response status.
-
#server_header(method: :head, path: '/', **kwargs) ⇒ String?
Sends an HTTP request and returns the
Server
header. -
#ssl? ⇒ Boolean
Determines if the HTTP connect is using SSL/TLS.
-
#trace(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
TRACE
HTTP request. -
#unlock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a
UNLOCK
HTTP request.
Constructor Details
#initialize(host, port, proxy: nil, ssl: port == 443, headers: {}, user_agent: self.class.user_agent, cookie: nil, user: nil, password: nil) {|_self| ... } ⇒ HTTP
Initializes an HTTP connection.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/ronin/support/network/http.rb', line 249 def initialize(host,port, proxy: nil, ssl: port == 443, # header options headers: {}, user_agent: self.class.user_agent, cookie: nil, # Basic-Auth options user: nil, password: nil) @host = DNS::IDN.to_ascii(host) @port = port.to_i @headers = headers self.user_agent = user_agent if user_agent self. = if @user = user @password = password if proxy @proxy = URI(proxy) @http = Net::HTTP.new( @host, @port, @proxy.host, @proxy.port, @proxy.user, @proxy.password ) else @http = Net::HTTP.new(@host,@port) end case ssl when true then initialize_ssl when Hash then initialize_ssl(**ssl) end yield self if block_given? end |
Instance Attribute Details
#cookie ⇒ Cookie?
The default cookie params to add to every request.
167 168 169 |
# File 'lib/ronin/support/network/http.rb', line 167 def @cookie end |
#headers ⇒ Hash{String => String,Array} (readonly)
Additional headers to add to every request.
152 153 154 |
# File 'lib/ronin/support/network/http.rb', line 152 def headers @headers end |
#host ⇒ String (readonly)
The host to connect to.
142 143 144 |
# File 'lib/ronin/support/network/http.rb', line 142 def host @host end |
#password ⇒ String? (readonly)
The HTTP Baic-Auth password to add to every request.
162 163 164 |
# File 'lib/ronin/support/network/http.rb', line 162 def password @password end |
#port ⇒ Integer (readonly)
The port to connect to.
147 148 149 |
# File 'lib/ronin/support/network/http.rb', line 147 def port @port end |
#proxy ⇒ URI::HTTP, ... (readonly)
The proxy to send requests through.
137 138 139 |
# File 'lib/ronin/support/network/http.rb', line 137 def proxy @proxy end |
#user ⇒ String? (readonly)
The HTTP Baic-Auth user to add to every request.
157 158 159 |
# File 'lib/ronin/support/network/http.rb', line 157 def user @user end |
#user_agent ⇒ String?
The User-Agent
header value.
561 562 563 |
# File 'lib/ronin/support/network/http.rb', line 561 def user_agent @user_agent end |
Class Method Details
.allowed_methods(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Array<Symbol>
Performs a OPTIONS
HTTP request for the given URI and parses the
Allow
response header.
2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 |
# File 'lib/ronin/support/network/http.rb', line 2328 def self.allowed_methods(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.allowed_methods(path,**kwargs) end |
.connect(host, port, ssl: port == 443, **kwargs) {|http| ... } ⇒ HTTP?
Creates a HTTP connection to the host nad port.
472 473 474 475 476 477 478 479 480 481 |
# File 'lib/ronin/support/network/http.rb', line 472 def self.connect(host,port, ssl: port == 443, **kwargs) http = new(host,port, ssl: ssl, **kwargs) if block_given? yield http http.close else return http end end |
.connect_uri(url, ssl: nil, user: nil, password: nil, **kwargs) {|http| ... } ⇒ HTTP?
Creates a HTTP connection using the URI.
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
# File 'lib/ronin/support/network/http.rb', line 508 def self.connect_uri(url, ssl: nil, user: nil, password: nil, **kwargs, &block) case url when URI::HTTP host = url.host port = url.port user ||= url.user password ||= url.password ssl ||= (url.scheme == 'https') when String uri = Addressable::URI.parse(url) host = uri.host port = uri.inferred_port user ||= uri.user password ||= uri.password ssl ||= (uri.scheme == 'https') when Addressable::URI host = url.host port = url.inferred_port user ||= url.user password ||= url.password ssl ||= (url.scheme == 'https') else raise(ArgumentError,"url must be a URI::HTTP, Addressable::URI, or a String: #{url.inspect}") end return connect(host,port, ssl: ssl, user: user, password: password, **kwargs, &block) end |
.copy(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a COPY
request for the given URI.
1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 |
# File 'lib/ronin/support/network/http.rb', line 1769 def self.copy(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.copy(path,**kwargs,&block) end |
.delete(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a DELETE
request for the given URI.
1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 |
# File 'lib/ronin/support/network/http.rb', line 1822 def self.delete(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.delete(path,**kwargs,&block) end |
.get(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a GET
request for the given URI.
1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 |
# File 'lib/ronin/support/network/http.rb', line 1875 def self.get(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.get(path,**kwargs,&block) end |
.get_body(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String
Performs a GET
request for the given URI and returns the response
body.
2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 |
# File 'lib/ronin/support/network/http.rb', line 2016 def self.get_body(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.get_body(path,**kwargs) end |
.get_cookies(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Array<SetCookie>?
Sends an HTTP request and returns the parsed Set-Cookie
header(s).
1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 |
# File 'lib/ronin/support/network/http.rb', line 1969 def self.(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.(path, **kwargs) end |
.get_headers(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Hash{String => String}
Performs a GET
request for the given URI and returns the response
headers.
1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 |
# File 'lib/ronin/support/network/http.rb', line 1923 def self.get_headers(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.get_headers(path,**kwargs) end |
.head(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a HEAD
request for the given URI.
2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 |
# File 'lib/ronin/support/network/http.rb', line 2068 def self.head(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.head(path,**kwargs,&block) end |
.lock(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a LOCK
request for the given URI.
2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 |
# File 'lib/ronin/support/network/http.rb', line 2121 def self.lock(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.lock(path,**kwargs,&block) end |
.mkcol(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a MKCOL
request for the given URI.
2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 |
# File 'lib/ronin/support/network/http.rb', line 2174 def self.mkcol(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.mkcol(path,**kwargs,&block) end |
.move(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a MOVE
request for the given URI.
2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 |
# File 'lib/ronin/support/network/http.rb', line 2227 def self.move(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.move(path,**kwargs,&block) end |
.ok?(method = :head, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Boolean
Sends a HTTP request and determines if the response status was 200.
The HTTP method to use for the request.
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 |
# File 'lib/ronin/support/network/http.rb', line 1523 def self.ok?(method=:head,url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.ok?(method,path,**kwargs) end |
.options(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a OPTIONS
request for the given URI.
2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 |
# File 'lib/ronin/support/network/http.rb', line 2280 def self.(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.(path,**kwargs,&block) end |
.patch(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a PATCH
request for the given URI.
2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 |
# File 'lib/ronin/support/network/http.rb', line 2380 def self.patch(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.patch(path,**kwargs,&block) end |
.post(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a POST
request for the given URI.
2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 |
# File 'lib/ronin/support/network/http.rb', line 2433 def self.post(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.post(path,**kwargs,&block) end |
.post_body(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String
Performs a POST
request for the given URI and returns the response
body.
2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 |
# File 'lib/ronin/support/network/http.rb', line 2528 def self.post_body(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.post_body(path,**kwargs) end |
.post_headers(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Hash{String => String}
Performs a POST
request on the given URI and returns the response
headers.
2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 |
# File 'lib/ronin/support/network/http.rb', line 2481 def self.post_headers(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.post_headers(path,**kwargs) end |
.powered_by_header(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String?
Sends an HTTP request and returns the X-Powered-By
header.
1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 |
# File 'lib/ronin/support/network/http.rb', line 1666 def self.powered_by_header(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.powered_by_header(path: path, **kwargs) end |
.propfind(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a PROPFIND
request for the given URI.
2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 |
# File 'lib/ronin/support/network/http.rb', line 2580 def self.propfind(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.propfind(path,**kwargs,&block) end |
.proppatch(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a PROPPATCH
request for the given URI.
2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 |
# File 'lib/ronin/support/network/http.rb', line 2633 def self.proppatch(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.proppatch(path,**kwargs,&block) end |
.proxy ⇒ URI::HTTP, ...
If the RONIN_HTTP_PROXY
environment variable is specified, it
will be used as the default value.
If the HTTP_PROXY
environment variable is specified, it will
be used as the default value.
The Ronin HTTP proxy to use.
59 60 61 62 63 64 65 |
# File 'lib/ronin/support/network/http.rb', line 59 def self.proxy @proxy ||= if ENV['RONIN_HTTP_PROXY'] Addressable::URI.parse(ENV['RONIN_HTTP_PROXY']) elsif ENV['HTTP_PROXY'] Addressable::URI.parse(ENV['HTTP_PROXY']) end end |
.proxy=(new_proxy) ⇒ URI::HTTP, ...
Sets the Ronin HTTP proxy to use.
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ronin/support/network/http.rb', line 82 def self.proxy=(new_proxy) @proxy = case new_proxy when URI::HTTP, Addressable::URI new_proxy when String Addressable::URI.parse(new_proxy) when nil nil else raise(ArgumentError,"invalid proxy value (#{new_proxy.inspect}), must be either a URI::HTTP, Addressable::URI, String, or nil") end end |
.put(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a PUT
request for the given URI.
2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 |
# File 'lib/ronin/support/network/http.rb', line 2686 def self.put(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.put(path,**kwargs,&block) end |
.request(method, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs and arbitrary HTTP request.
The HTTP method to use for the request.
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 |
# File 'lib/ronin/support/network/http.rb', line 1420 def self.request(method,url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(uri, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.request(method,path,**kwargs,&block) end |
.response_body(method = :get, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String
Sends an arbitrary HTTP request and returns the response body.
The HTTP method to use for the request.
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 |
# File 'lib/ronin/support/network/http.rb', line 1717 def self.response_body(method=:get,url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.response_body(method,path,**kwargs) end |
.response_headers(method = :head, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Hash{String => String}
Sends an arbitrary HTTP request and returns the response headers.
The HTTP method to use for the request.
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 |
# File 'lib/ronin/support/network/http.rb', line 1574 def self.response_headers(method=:head,url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.response_headers(method,path,**kwargs) end |
.response_status(method = :head, url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ Integer
Sends an arbitrary HTTP request and returns the response status.
The HTTP method to use for the request.
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 |
# File 'lib/ronin/support/network/http.rb', line 1472 def self.response_status(method=:head,url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.response_status(method,path,**kwargs) end |
.server_header(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) ⇒ String?
Sends an HTTP request and returns the Server
header.
1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 |
# File 'lib/ronin/support/network/http.rb', line 1620 def self.server_header(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.server_header(path: path, **kwargs) end |
.trace(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a TRACE
request for the given URI.
2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 |
# File 'lib/ronin/support/network/http.rb', line 2739 def self.trace(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.trace(path,**kwargs,&block) end |
.unlock(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a UNLOCK
request for the given URI.
2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 |
# File 'lib/ronin/support/network/http.rb', line 2792 def self.unlock(url, proxy: self.proxy, ssl: nil, headers: {}, user_agent: nil, cookie: nil, user: nil, password: nil, **kwargs, &block) uri = case url when Addressable::URI, URI::HTTP url when String Addressable::URI.parse(url) else raise(ArgumentError,"URL argument must be either a Addressable::URI, URI::HTTP, or a String: #{url.inspect}") end path = uri.request_uri http = connect_uri(url, proxy: proxy, ssl: ssl, headers: headers, user_agent: user_agent, cookie: , user: user, password: password) http.unlock(path,**kwargs,&block) end |
.user_agent ⇒ String?
The default Ronin HTTP User-Agent
string.
103 104 105 |
# File 'lib/ronin/support/network/http.rb', line 103 def self.user_agent @user_agent end |
.user_agent=(new_user_agent) ⇒ String?
Sets the default Ronin HTTP User-Agent
string.
The new User-Agent
default value.
- If a
Symbol
or aString
is given, then the user_agent value will be set. - If
nil
is given, then the user_agent value will be cleared.
127 128 129 130 131 132 |
# File 'lib/ronin/support/network/http.rb', line 127 def self.user_agent=(new_user_agent) @user_agent = case new_user_agent when Symbol then UserAgents[new_user_agent] else new_user_agent end end |
Instance Method Details
#allowed_methods(path = '*', **kwargs) ⇒ Array<Symbol>
Sends a OPTIONS
HTTP request and parses the Allow
response
header.
1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
# File 'lib/ronin/support/network/http.rb', line 1169 def allowed_methods(path='*',**kwargs) response = (path,**kwargs) allow = response['Allow'] methods = allow.split(', ') methods.map! do |method| method.downcase! method.to_sym end return methods end |
#close ⇒ Object
Closes the HTTP connection.
1386 1387 1388 |
# File 'lib/ronin/support/network/http.rb', line 1386 def close @http.finish if @http.started? end |
#copy(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a COPY
HTTP request.
931 932 933 |
# File 'lib/ronin/support/network/http.rb', line 931 def copy(path,**kwargs,&block) request(:copy,path,**kwargs,&block) end |
#delete(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a DELETE
HTTP request.
954 955 956 |
# File 'lib/ronin/support/network/http.rb', line 954 def delete(path,**kwargs,&block) request(:delete,path,**kwargs,&block) end |
#get(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a GET
HTTP request.
977 978 979 |
# File 'lib/ronin/support/network/http.rb', line 977 def get(path,**kwargs,&block) request(:get,path,**kwargs,&block) end |
#get_body(path, **kwargs) ⇒ String
Sends a GET
HTTP request and returns the response body.
1036 1037 1038 |
# File 'lib/ronin/support/network/http.rb', line 1036 def get_body(path,**kwargs) response_body(:get,path,**kwargs) end |
#get_cookies(path, **kwargs) ⇒ Array<SetCookie>
Sends an HTTP request and returns the parsed Set-Cookie
header(s).
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 |
# File 'lib/ronin/support/network/http.rb', line 1011 def (path, **kwargs) response = request(:get,path,**kwargs) if ( = response.get_fields('Set-Cookie')) .map do || SetCookie.parse() end else [] end end |
#get_headers(path, **kwargs) ⇒ Hash{String => String}
Sends a GET
HTTP request and returns the response headers.
994 995 996 |
# File 'lib/ronin/support/network/http.rb', line 994 def get_headers(path,**kwargs) response_headers(:get,path,**kwargs) end |
#head(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a HEAD
HTTP request.
1059 1060 1061 |
# File 'lib/ronin/support/network/http.rb', line 1059 def head(path,**kwargs,&block) request(:head,path,**kwargs,&block) end |
#lock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a LOCK
HTTP request.
1082 1083 1084 |
# File 'lib/ronin/support/network/http.rb', line 1082 def lock(path,**kwargs,&block) request(:lock,path,**kwargs,&block) end |
#mkcol(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a MKCOL
HTTP request.
1105 1106 1107 |
# File 'lib/ronin/support/network/http.rb', line 1105 def mkcol(path,**kwargs,&block) request(:mkcol,path,**kwargs,&block) end |
#move(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a MOVE
HTTP request.
1128 1129 1130 |
# File 'lib/ronin/support/network/http.rb', line 1128 def move(path,**kwargs,&block) request(:move,path,**kwargs,&block) end |
#ok?(method = :head, path, **kwargs) ⇒ Boolean
Sends a HTTP request and determines if the response status was 200.
The HTTP method to use for the request.
812 813 814 |
# File 'lib/ronin/support/network/http.rb', line 812 def ok?(method=:head,path,**kwargs) response_status(method,path,**kwargs) == 200 end |
#options(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a OPTIONS
HTTP request.
1151 1152 1153 |
# File 'lib/ronin/support/network/http.rb', line 1151 def (path,**kwargs,&block) request(:options,path,**kwargs,&block) end |
#patch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a PATCH
HTTP request.
1201 1202 1203 |
# File 'lib/ronin/support/network/http.rb', line 1201 def patch(path,**kwargs,&block) request(:patch,path,**kwargs,&block) end |
#post(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a POST
HTTP request.
1224 1225 1226 |
# File 'lib/ronin/support/network/http.rb', line 1224 def post(path,**kwargs,&block) request(:post,path,**kwargs,&block) end |
#post_body(path, **kwargs) ⇒ String
Sends a POST
HTTP request and returns the response body.
1258 1259 1260 |
# File 'lib/ronin/support/network/http.rb', line 1258 def post_body(path,**kwargs) response_body(:post,path,**kwargs) end |
#post_headers(path, **kwargs) ⇒ Hash{String => String}
Sends a POST
HTTP request and returns the response headers.
1241 1242 1243 |
# File 'lib/ronin/support/network/http.rb', line 1241 def post_headers(path,**kwargs) response_headers(:post,path,**kwargs) end |
#powered_by_header(method: :head, path: '/', **kwargs) ⇒ String?
Sends an HTTP request and returns the X-Powered-By
header.
The HTTP method to use for the request.
885 886 887 888 |
# File 'lib/ronin/support/network/http.rb', line 885 def powered_by_header(method: :head, path: '/',**kwargs) response = request(method,path,**kwargs) response['X-Powered-By'] end |
#prop_find {|response| ... } ⇒ Net::HTTPResponse
Sends a PROPFIND
HTTP request.
1285 1286 1287 |
# File 'lib/ronin/support/network/http.rb', line 1285 def propfind(path,**kwargs,&block) request(:propfind,path,**kwargs,&block) end |
#prop_patch {|response| ... } ⇒ Net::HTTPResponse
Sends a PROPPATCH
HTTP request.
1310 1311 1312 |
# File 'lib/ronin/support/network/http.rb', line 1310 def proppatch(path,**kwargs,&block) request(:proppatch,path,**kwargs,&block) end |
#propfind(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a PROPFIND
HTTP request.
1281 1282 1283 |
# File 'lib/ronin/support/network/http.rb', line 1281 def propfind(path,**kwargs,&block) request(:propfind,path,**kwargs,&block) end |
#proppatch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a PROPPATCH
HTTP request.
1306 1307 1308 |
# File 'lib/ronin/support/network/http.rb', line 1306 def proppatch(path,**kwargs,&block) request(:proppatch,path,**kwargs,&block) end |
#put(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a PUT
HTTP request.
1331 1332 1333 |
# File 'lib/ronin/support/network/http.rb', line 1331 def put(path,**kwargs,&block) request(:put,path,**kwargs,&block) end |
#request(method, path, query: nil, query_params: nil, headers: nil, user_agent: @user_agent, cookie: @cookie, user: @user, password: @password, body: nil, form_data: nil, **additional_headers) {|response| ... } ⇒ Net::HTTPResponse
Sends an arbitrary HTTP request.
The HTTP method to use for the request.
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
# File 'lib/ronin/support/network/http.rb', line 697 def request(method,path, # query string keyword arguments query: nil, query_params: nil, # header keyword arguments headers: nil, user_agent: @user_agent, cookie: @cookie, # Basic-Auth keyword arguments user: @user, password: @password, # request body keyword arguments body: nil, form_data: nil, **additional_headers, &block) request = Request.build(method,path, headers: @headers, user_agent: user_agent, cookie: , user: user, password: password, query: query, query_params: query_params, body: body, form_data: form_data) if headers # populate any arbitrary headers headers.each do |name,value| request[name] = value end end unless additional_headers.empty? # set additional keyword argument headers (ex: `referer: '...'` additional_headers.each do |name,value| request[name] = value end end return @http.request(request,&block) end |
#response_body(method = :get, path, **kwargs) ⇒ String
Sends an arbitrary HTTP request and returns the response body.
The HTTP method to use for the request.
908 909 910 |
# File 'lib/ronin/support/network/http.rb', line 908 def response_body(method=:get,path,**kwargs) request(method,path,**kwargs).body end |
#response_headers(method = :head, path, **kwargs) ⇒ Hash{String => String}
Sends an arbitrary HTTP request and returns the response headers.
The HTTP method to use for the request.
834 835 836 837 838 839 840 841 842 |
# File 'lib/ronin/support/network/http.rb', line 834 def response_headers(method=:head,path,**kwargs) headers = {} request(method,path,**kwargs).each_capitalized do |name,value| headers[name] = value end return headers end |
#response_status(method = :head, path, **kwargs) ⇒ Integer
Sends an arbitrary HTTP request and returns the response status.
The HTTP method to use for the request.
789 790 791 792 |
# File 'lib/ronin/support/network/http.rb', line 789 def response_status(method=:head,path,**kwargs) response = request(method,path,**kwargs) response.code.to_i end |
#server_header(method: :head, path: '/', **kwargs) ⇒ String?
Sends an HTTP request and returns the Server
header.
The HTTP method to use for the request.
862 863 864 865 |
# File 'lib/ronin/support/network/http.rb', line 862 def server_header(method: :head, path: '/',**kwargs) response = request(method,path,**kwargs) response['Server'] end |
#ssl? ⇒ Boolean
Determines if the HTTP connect is using SSL/TLS.
550 551 552 |
# File 'lib/ronin/support/network/http.rb', line 550 def ssl? @http.use_ssl? end |
#trace(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a TRACE
HTTP request.
1354 1355 1356 |
# File 'lib/ronin/support/network/http.rb', line 1354 def trace(path,**kwargs,&block) request(:trace,path,**kwargs,&block) end |
#unlock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Sends a UNLOCK
HTTP request.
1377 1378 1379 |
# File 'lib/ronin/support/network/http.rb', line 1377 def unlock(path,**kwargs,&block) request(:unlock,path,**kwargs,&block) end |