ronin-support 0.5.2 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -6
- data/.gitignore +7 -6
- data/.mailmap +1 -0
- data/.ruby-version +1 -1
- data/.yardopts +0 -1
- data/ChangeLog.md +518 -148
- data/Gemfile +17 -16
- data/README.md +107 -52
- data/Rakefile +28 -8
- data/data/text/homoglyphs/ascii.txt +8 -0
- data/data/text/homoglyphs/cyrillic.txt +33 -0
- data/data/text/homoglyphs/full_width.txt +81 -0
- data/data/text/homoglyphs/greek.txt +21 -0
- data/data/text/homoglyphs/latin_numbers.txt +14 -0
- data/data/text/homoglyphs/punctuation.txt +7 -0
- data/data/text/patterns/network/public_suffix.rb.erb +44 -0
- data/examples/ssl_proxy.rb +38 -0
- data/examples/tcp_proxy.rb +41 -0
- data/gemspec.yml +16 -15
- data/lib/ronin/support/archive/core_ext/file.rb +118 -0
- data/lib/ronin/{formatting/sql.rb → support/archive/core_ext.rb} +3 -4
- data/lib/ronin/support/archive/mixin.rb +213 -0
- data/lib/ronin/support/archive/tar/reader.rb +135 -0
- data/lib/ronin/support/archive/tar/writer.rb +197 -0
- data/lib/ronin/support/archive/tar.rb +155 -0
- data/lib/ronin/support/archive/zip/reader/entry.rb +134 -0
- data/lib/ronin/support/archive/zip/reader/statistics.rb +76 -0
- data/lib/ronin/support/archive/zip/reader.rb +273 -0
- data/lib/ronin/support/archive/zip/writer.rb +175 -0
- data/lib/ronin/support/archive/zip.rb +105 -0
- data/lib/ronin/support/archive.rb +211 -0
- data/lib/ronin/support/binary/array.rb +255 -0
- data/lib/ronin/support/binary/bit_flip.rb +147 -0
- data/lib/ronin/support/binary/buffer.rb +2027 -0
- data/lib/ronin/support/binary/byte_slice.rb +324 -0
- data/lib/ronin/{formatting/extensions/binary → support/binary/core_ext}/array.rb +25 -11
- data/lib/ronin/support/binary/core_ext/float.rb +80 -0
- data/lib/ronin/support/binary/core_ext/integer.rb +305 -0
- data/lib/ronin/support/binary/core_ext/io.rb +38 -0
- data/lib/ronin/support/binary/core_ext/string.rb +162 -0
- data/lib/ronin/{formatting/extensions/text.rb → support/binary/core_ext.rb} +6 -6
- data/lib/ronin/support/binary/cstring.rb +259 -0
- data/lib/ronin/support/binary/ctypes/aggregate_type.rb +98 -0
- data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/arm.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/mips.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/x86.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch.rb +30 -0
- data/lib/ronin/support/binary/ctypes/array_object_type.rb +164 -0
- data/lib/ronin/support/binary/ctypes/array_type.rb +232 -0
- data/lib/ronin/support/binary/ctypes/big_endian.rb +195 -0
- data/lib/ronin/support/binary/ctypes/char_type.rb +59 -0
- data/lib/ronin/support/binary/ctypes/char_types.rb +39 -0
- data/lib/ronin/support/binary/ctypes/enum_type.rb +181 -0
- data/lib/ronin/support/binary/ctypes/float32_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/float64_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/float_type.rb +62 -0
- data/lib/ronin/support/binary/ctypes/int16_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/int32_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/int64_type.rb +50 -0
- data/lib/ronin/support/{support.rb → binary/ctypes/int8_type.rb} +20 -21
- data/lib/ronin/support/binary/ctypes/int_type.rb +62 -0
- data/lib/ronin/support/binary/ctypes/little_endian.rb +195 -0
- data/lib/ronin/support/binary/ctypes/mixin.rb +135 -0
- data/lib/ronin/support/binary/ctypes/native.rb +205 -0
- data/lib/ronin/support/binary/ctypes/network.rb +29 -0
- data/lib/ronin/support/binary/ctypes/object_type.rb +55 -0
- data/lib/ronin/support/binary/ctypes/os/bsd.rb +65 -0
- data/lib/ronin/support/binary/ctypes/os/freebsd.rb +215 -0
- data/lib/ronin/support/binary/ctypes/os/linux.rb +193 -0
- data/lib/ronin/support/binary/ctypes/os/macos.rb +151 -0
- data/lib/ronin/support/binary/ctypes/os/netbsd.rb +147 -0
- data/lib/ronin/support/binary/ctypes/os/openbsd.rb +168 -0
- data/lib/ronin/support/binary/ctypes/os/unix.rb +78 -0
- data/lib/ronin/support/binary/ctypes/os/windows.rb +125 -0
- data/lib/ronin/support/binary/ctypes/os.rb +125 -0
- data/lib/ronin/support/binary/ctypes/scalar_type.rb +200 -0
- data/lib/ronin/support/binary/ctypes/string_type.rb +143 -0
- data/lib/ronin/support/binary/ctypes/struct_object_type.rb +173 -0
- data/lib/ronin/support/binary/ctypes/struct_type.rb +359 -0
- data/lib/ronin/support/binary/ctypes/type.rb +193 -0
- data/lib/ronin/support/binary/ctypes/type_resolver.rb +206 -0
- data/lib/ronin/support/binary/ctypes/uint16_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/uint32_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/uint64_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/uint8_type.rb +41 -0
- data/lib/ronin/support/binary/ctypes/uint_type.rb +59 -0
- data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +258 -0
- data/lib/ronin/support/binary/ctypes/union_object_type.rb +173 -0
- data/lib/ronin/support/binary/ctypes/union_type.rb +261 -0
- data/lib/ronin/support/binary/ctypes.rb +462 -0
- data/lib/ronin/support/binary/hexdump/core_ext/file.rb +118 -0
- data/lib/ronin/support/binary/hexdump/core_ext/string.rb +115 -0
- data/lib/ronin/support/binary/hexdump/core_ext.rb +20 -0
- data/lib/ronin/support/binary/hexdump/parser.rb +492 -0
- data/lib/ronin/support/binary/hexdump.rb +20 -0
- data/lib/ronin/support/binary/memory.rb +268 -0
- data/lib/ronin/support/binary/packet.rb +33 -0
- data/lib/ronin/support/binary/stack.rb +256 -0
- data/lib/ronin/support/binary/stream/methods.rb +1755 -0
- data/lib/ronin/support/binary/stream.rb +151 -0
- data/lib/ronin/support/binary/struct/member.rb +86 -0
- data/lib/ronin/support/binary/struct.rb +830 -0
- data/lib/ronin/support/binary/template.rb +284 -0
- data/lib/ronin/support/binary/union.rb +162 -0
- data/lib/ronin/{formatting/extensions → support}/binary.rb +10 -10
- data/lib/ronin/support/cli/ansi.rb +330 -0
- data/lib/ronin/support/cli/io_shell/core_ext/io.rb +67 -0
- data/lib/ronin/{extensions/meta.rb → support/cli/io_shell/core_ext.rb} +3 -4
- data/lib/ronin/support/cli/io_shell.rb +161 -0
- data/lib/ronin/support/cli/printing.rb +216 -0
- data/lib/ronin/support/cli.rb +20 -0
- data/lib/ronin/support/compression/core_ext/file.rb +70 -0
- data/lib/ronin/support/compression/core_ext/string.rb +101 -0
- data/lib/ronin/{fuzzing/extensions.rb → support/compression/core_ext.rb} +3 -4
- data/lib/ronin/support/compression/gzip/reader.rb +70 -0
- data/lib/ronin/support/compression/gzip/writer.rb +74 -0
- data/lib/ronin/support/compression/gzip.rb +105 -0
- data/lib/ronin/support/compression/mixin.rb +180 -0
- data/lib/ronin/{network/extensions/esmtp/net.rb → support/compression/zlib.rb} +6 -7
- data/lib/ronin/support/compression.rb +174 -0
- data/lib/ronin/{extensions → support/core_ext}/enumerable.rb +2 -3
- data/lib/ronin/{extensions → support/core_ext}/file.rb +2 -31
- data/lib/ronin/support/core_ext/integer.rb +37 -0
- data/lib/ronin/support/core_ext/ipaddr.rb +65 -0
- data/lib/ronin/{extensions → support/core_ext}/kernel.rb +7 -6
- data/lib/ronin/{extensions → support/core_ext}/resolv.rb +2 -25
- data/lib/ronin/{extensions → support/core_ext}/string.rb +114 -54
- data/lib/ronin/support/core_ext.rb +34 -0
- data/lib/ronin/support/crypto/cert.rb +522 -0
- data/lib/ronin/support/crypto/cert_chain.rb +204 -0
- data/lib/ronin/support/crypto/cipher/aes.rb +71 -0
- data/lib/ronin/support/crypto/cipher/aes128.rb +54 -0
- data/lib/ronin/support/crypto/cipher/aes256.rb +54 -0
- data/lib/ronin/support/crypto/cipher.rb +194 -0
- data/lib/ronin/support/crypto/core_ext/file.rb +660 -0
- data/lib/ronin/support/crypto/core_ext/string.rb +548 -0
- data/lib/ronin/{binary.rb → support/crypto/core_ext.rb} +4 -5
- data/lib/ronin/{network/mixins/mixin.rb → support/crypto/hmac.rb} +18 -28
- data/lib/ronin/support/crypto/key/dh.rb +122 -0
- data/lib/ronin/support/crypto/key/dsa.rb +103 -0
- data/lib/ronin/support/crypto/key/ec.rb +99 -0
- data/lib/ronin/support/crypto/key/methods.rb +163 -0
- data/lib/ronin/support/crypto/key/rsa.rb +169 -0
- data/lib/ronin/support/crypto/key.rb +105 -0
- data/lib/ronin/support/crypto/mixin.rb +620 -0
- data/lib/ronin/{network/extensions/http/net.rb → support/crypto/openssl.rb} +6 -7
- data/lib/ronin/support/crypto.rb +779 -0
- data/lib/ronin/support/encoding/base16/core_ext/string.rb +63 -0
- data/lib/ronin/{formatting/binary.rb → support/encoding/base16/core_ext.rb} +3 -4
- data/lib/ronin/support/encoding/base16.rb +82 -0
- data/lib/ronin/support/encoding/base32/core_ext/string.rb +63 -0
- data/lib/ronin/support/encoding/base32/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/base32.rb +164 -0
- data/lib/ronin/support/encoding/base64/core_ext/string.rb +76 -0
- data/lib/ronin/support/encoding/base64/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/base64.rb +78 -0
- data/lib/ronin/support/encoding/c/core_ext/integer.rb +82 -0
- data/lib/ronin/support/encoding/c/core_ext/string.rb +125 -0
- data/lib/ronin/support/encoding/c/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/c.rb +277 -0
- data/lib/ronin/support/encoding/core_ext/string.rb +107 -0
- data/lib/ronin/support/encoding/core_ext.rb +33 -0
- data/lib/ronin/support/encoding/hex/core_ext/integer.rb +82 -0
- data/lib/ronin/support/encoding/hex/core_ext/string.rb +133 -0
- data/lib/ronin/support/encoding/hex/core_ext.rb +22 -0
- data/lib/ronin/support/encoding/hex.rb +248 -0
- data/lib/ronin/support/encoding/html/core_ext/integer.rb +106 -0
- data/lib/ronin/support/encoding/html/core_ext/string.rb +130 -0
- data/lib/ronin/support/encoding/html/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/html.rb +233 -0
- data/lib/ronin/support/encoding/http/core_ext/integer.rb +95 -0
- data/lib/ronin/support/encoding/http/core_ext/string.rb +129 -0
- data/lib/ronin/support/encoding/http/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/http.rb +241 -0
- data/lib/ronin/support/encoding/js/core_ext/integer.rb +67 -0
- data/lib/ronin/support/encoding/js/core_ext/string.rb +125 -0
- data/lib/ronin/support/encoding/js/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/js.rb +279 -0
- data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +87 -0
- data/lib/ronin/support/encoding/powershell/core_ext/string.rb +145 -0
- data/lib/ronin/support/encoding/powershell/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/powershell.rb +297 -0
- data/lib/ronin/{formatting/extensions/http/integer.rb → support/encoding/punycode/core_ext/string.rb} +23 -29
- data/lib/ronin/support/encoding/punycode/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/punycode.rb +76 -0
- data/lib/ronin/support/encoding/quoted_printable/core_ext/string.rb +75 -0
- data/lib/ronin/support/encoding/quoted_printable/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/quoted_printable.rb +102 -0
- data/lib/ronin/support/encoding/ruby/core_ext/string.rb +129 -0
- data/lib/ronin/support/encoding/ruby/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/ruby.rb +235 -0
- data/lib/ronin/support/encoding/shell/core_ext/integer.rb +89 -0
- data/lib/ronin/support/encoding/shell/core_ext/string.rb +134 -0
- data/lib/ronin/support/encoding/shell/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/shell.rb +293 -0
- data/lib/ronin/{network/extensions → support/encoding}/smtp.rb +4 -4
- data/lib/ronin/support/encoding/sql/core_ext/string.rb +114 -0
- data/lib/ronin/{formatting/html.rb → support/encoding/sql/core_ext.rb} +3 -4
- data/lib/ronin/support/encoding/sql.rb +124 -0
- data/lib/ronin/support/encoding/uri/core_ext/integer.rb +149 -0
- data/lib/ronin/support/encoding/uri/core_ext/string.rb +195 -0
- data/lib/ronin/support/encoding/uri/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/uri.rb +424 -0
- data/lib/ronin/support/encoding/uuencoding/core_ext/string.rb +73 -0
- data/lib/ronin/support/encoding/uuencoding/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/uuencoding.rb +70 -0
- data/lib/ronin/support/encoding/xml/core_ext/integer.rb +100 -0
- data/lib/ronin/support/encoding/xml/core_ext/string.rb +124 -0
- data/lib/ronin/support/encoding/xml/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/xml.rb +328 -0
- data/lib/ronin/support/encoding.rb +46 -0
- data/lib/ronin/support/home.rb +88 -0
- data/lib/ronin/{network/network.rb → support/mixin.rb} +17 -20
- data/lib/ronin/support/network/asn/dns_record.rb +112 -0
- data/lib/ronin/support/network/asn/list.rb +269 -0
- data/lib/ronin/support/network/asn/record.rb +164 -0
- data/lib/ronin/support/network/asn/record_set.rb +226 -0
- data/lib/ronin/support/network/asn.rb +88 -0
- data/lib/ronin/{binary/hexdump.rb → support/network/core_ext.rb} +3 -4
- data/lib/ronin/support/network/dns/idn.rb +38 -0
- data/lib/ronin/support/network/dns/mixin.rb +941 -0
- data/lib/ronin/support/network/dns/resolver.rb +707 -0
- data/lib/ronin/support/network/dns.rb +1109 -0
- data/lib/ronin/support/network/domain.rb +70 -0
- data/lib/ronin/support/network/email_address.rb +574 -0
- data/lib/ronin/support/network/esmtp/mixin.rb +115 -0
- data/lib/ronin/support/network/exceptions.rb +43 -0
- data/lib/ronin/support/network/ftp/mixin.rb +106 -0
- data/lib/ronin/support/network/host.rb +1473 -0
- data/lib/ronin/support/network/http/cookie.rb +245 -0
- data/lib/ronin/support/network/http/core_ext/uri/http.rb +63 -0
- data/lib/ronin/support/network/http/core_ext.rb +19 -0
- data/lib/ronin/support/network/http/mixin.rb +890 -0
- data/lib/ronin/support/network/http/request.rb +215 -0
- data/lib/ronin/support/network/http/set_cookie.rb +210 -0
- data/lib/ronin/support/network/http/user_agents.rb +115 -0
- data/lib/ronin/support/network/http.rb +2582 -0
- data/lib/ronin/support/network/imap/mixin.rb +133 -0
- data/lib/ronin/support/network/ip/mixin.rb +114 -0
- data/lib/ronin/support/network/ip.rb +540 -0
- data/lib/ronin/support/network/ip_range/cidr.rb +252 -0
- data/lib/ronin/support/network/ip_range/glob.rb +309 -0
- data/lib/ronin/support/network/ip_range/range.rb +249 -0
- data/lib/ronin/support/network/ip_range.rb +284 -0
- data/lib/ronin/support/network/mixin.rb +58 -0
- data/lib/ronin/support/network/packet.rb +27 -0
- data/lib/ronin/support/network/pop3/mixin.rb +113 -0
- data/lib/ronin/support/network/proxy.rb +602 -0
- data/lib/ronin/support/network/public_suffix/list.rb +339 -0
- data/lib/ronin/support/network/public_suffix/suffix.rb +118 -0
- data/lib/ronin/support/network/public_suffix/suffix_set.rb +150 -0
- data/lib/ronin/support/network/public_suffix.rb +41 -0
- data/lib/ronin/support/network/smtp/email.rb +190 -0
- data/lib/ronin/support/network/smtp/mixin.rb +290 -0
- data/lib/ronin/support/network/smtp.rb +19 -0
- data/lib/ronin/support/network/ssl/local_cert.rb +114 -0
- data/lib/ronin/support/network/ssl/local_key.rb +84 -0
- data/lib/ronin/support/network/ssl/mixin.rb +740 -0
- data/lib/ronin/{network/extensions/imap/net.rb → support/network/ssl/openssl.rb} +6 -7
- data/lib/ronin/support/network/ssl/proxy.rb +296 -0
- data/lib/ronin/support/network/ssl.rb +173 -0
- data/lib/ronin/support/network/tcp/mixin.rb +400 -0
- data/lib/ronin/support/network/tcp/proxy.rb +435 -0
- data/lib/ronin/support/network/tcp.rb +443 -0
- data/lib/ronin/support/network/telnet/mixin.rb +150 -0
- data/lib/ronin/support/network/telnet.rb +90 -0
- data/lib/ronin/support/network/tld/list.rb +266 -0
- data/lib/ronin/support/network/tld.rb +41 -0
- data/lib/ronin/support/network/tls/mixin.rb +670 -0
- data/lib/ronin/support/network/tls/proxy.rb +135 -0
- data/lib/ronin/{network/mixins/dns.rb → support/network/tls.rb} +23 -25
- data/lib/ronin/support/network/udp/mixin.rb +389 -0
- data/lib/ronin/support/network/udp/proxy.rb +192 -0
- data/lib/ronin/support/network/udp.rb +435 -0
- data/lib/ronin/support/network/unix/mixin.rb +273 -0
- data/lib/ronin/support/network.rb +37 -0
- data/lib/ronin/support/path.rb +136 -0
- data/lib/ronin/{network/extensions/dns/net.rb → support/text/core_ext/regexp.rb} +5 -6
- data/lib/ronin/support/text/core_ext/string.rb +46 -0
- data/lib/ronin/{formatting.rb → support/text/core_ext.rb} +7 -9
- data/lib/ronin/support/text/entropy/core_ext/string.rb +45 -0
- data/lib/ronin/{formatting/http.rb → support/text/entropy/core_ext.rb} +3 -4
- data/lib/ronin/support/text/entropy.rb +66 -0
- data/lib/ronin/support/text/erb/mixin.rb +44 -0
- data/lib/ronin/support/text/erb.rb +19 -0
- data/lib/ronin/support/text/homoglyph/core_ext/string.rb +108 -0
- data/lib/ronin/{formatting/digest.rb → support/text/homoglyph/core_ext.rb} +3 -4
- data/lib/ronin/{network/http/exceptions/unknown_request.rb → support/text/homoglyph/exceptions.rb} +7 -6
- data/lib/ronin/support/text/homoglyph/table.rb +228 -0
- data/lib/ronin/support/text/homoglyph.rb +142 -0
- data/lib/ronin/support/text/mixin.rb +31 -0
- data/lib/ronin/support/text/patterns/credentials.rb +75 -0
- data/lib/ronin/support/text/patterns/crypto.rb +67 -0
- data/lib/ronin/support/text/patterns/file_system.rb +93 -0
- data/lib/ronin/support/text/patterns/language.rb +37 -0
- data/lib/ronin/support/text/patterns/network/public_suffix.rb +44 -0
- data/lib/ronin/support/text/patterns/network.rb +140 -0
- data/lib/ronin/support/text/patterns/numeric.rb +52 -0
- data/lib/ronin/support/text/patterns/pii.rb +105 -0
- data/lib/ronin/support/text/patterns/source_code.rb +148 -0
- data/lib/ronin/{extensions.rb → support/text/patterns.rb} +10 -13
- data/lib/ronin/support/text/random/mixin.rb +437 -0
- data/lib/ronin/support/text/random.rb +419 -0
- data/lib/ronin/support/text/typo/core_ext/string.rb +123 -0
- data/lib/ronin/support/text/typo/core_ext.rb +19 -0
- data/lib/ronin/support/text/typo/exceptions.rb +28 -0
- data/lib/ronin/support/text/typo/generator.rb +161 -0
- data/lib/ronin/support/text/typo.rb +260 -0
- data/lib/ronin/{formatting → support}/text.rb +10 -4
- data/lib/ronin/support/version.rb +3 -4
- data/lib/ronin/support.rb +17 -12
- data/ronin-support.gemspec +2 -1
- metadata +342 -291
- data/lib/ronin/binary/hexdump/parser.rb +0 -403
- data/lib/ronin/binary/struct.rb +0 -567
- data/lib/ronin/binary/template.rb +0 -454
- data/lib/ronin/extensions/ip_addr.rb +0 -216
- data/lib/ronin/extensions/meta/object.rb +0 -24
- data/lib/ronin/extensions/regexp.rb +0 -157
- data/lib/ronin/formatting/extensions/binary/base64.rb +0 -106
- data/lib/ronin/formatting/extensions/binary/file.rb +0 -77
- data/lib/ronin/formatting/extensions/binary/float.rb +0 -65
- data/lib/ronin/formatting/extensions/binary/integer.rb +0 -180
- data/lib/ronin/formatting/extensions/binary/string.rb +0 -345
- data/lib/ronin/formatting/extensions/digest/file.rb +0 -129
- data/lib/ronin/formatting/extensions/digest/string.rb +0 -86
- data/lib/ronin/formatting/extensions/digest.rb +0 -21
- data/lib/ronin/formatting/extensions/html/integer.rb +0 -142
- data/lib/ronin/formatting/extensions/html/string.rb +0 -194
- data/lib/ronin/formatting/extensions/html.rb +0 -21
- data/lib/ronin/formatting/extensions/http/string.rb +0 -110
- data/lib/ronin/formatting/extensions/http.rb +0 -21
- data/lib/ronin/formatting/extensions/sql/string.rb +0 -130
- data/lib/ronin/formatting/extensions/sql.rb +0 -20
- data/lib/ronin/formatting/extensions/text/array.rb +0 -137
- data/lib/ronin/formatting/extensions/text/string.rb +0 -297
- data/lib/ronin/formatting/extensions.rb +0 -24
- data/lib/ronin/fuzzing/extensions/string.rb +0 -209
- data/lib/ronin/fuzzing/fuzzer.rb +0 -110
- data/lib/ronin/fuzzing/fuzzing.rb +0 -360
- data/lib/ronin/fuzzing/mutator.rb +0 -161
- data/lib/ronin/fuzzing/repeater.rb +0 -81
- data/lib/ronin/fuzzing/template.rb +0 -133
- data/lib/ronin/fuzzing.rb +0 -21
- data/lib/ronin/mixin.rb +0 -89
- data/lib/ronin/network/dns.rb +0 -201
- data/lib/ronin/network/esmtp.rb +0 -113
- data/lib/ronin/network/extensions/dns.rb +0 -20
- data/lib/ronin/network/extensions/esmtp.rb +0 -20
- data/lib/ronin/network/extensions/http/uri/http.rb +0 -228
- data/lib/ronin/network/extensions/http.rb +0 -21
- data/lib/ronin/network/extensions/imap.rb +0 -20
- data/lib/ronin/network/extensions/pop3/net.rb +0 -24
- data/lib/ronin/network/extensions/pop3.rb +0 -20
- data/lib/ronin/network/extensions/smtp/net.rb +0 -24
- data/lib/ronin/network/extensions/ssl/net.rb +0 -24
- data/lib/ronin/network/extensions/ssl.rb +0 -20
- data/lib/ronin/network/extensions/tcp/net.rb +0 -24
- data/lib/ronin/network/extensions/tcp.rb +0 -20
- data/lib/ronin/network/extensions/telnet/net.rb +0 -24
- data/lib/ronin/network/extensions/telnet.rb +0 -20
- data/lib/ronin/network/extensions/udp/net.rb +0 -24
- data/lib/ronin/network/extensions/udp.rb +0 -20
- data/lib/ronin/network/extensions.rb +0 -29
- data/lib/ronin/network/ftp.rb +0 -149
- data/lib/ronin/network/http/exceptions.rb +0 -20
- data/lib/ronin/network/http/http.rb +0 -1122
- data/lib/ronin/network/http/proxy.rb +0 -330
- data/lib/ronin/network/http.rb +0 -22
- data/lib/ronin/network/imap.rb +0 -158
- data/lib/ronin/network/mixins/esmtp.rb +0 -164
- data/lib/ronin/network/mixins/ftp.rb +0 -155
- data/lib/ronin/network/mixins/http.rb +0 -227
- data/lib/ronin/network/mixins/imap.rb +0 -156
- data/lib/ronin/network/mixins/pop3.rb +0 -149
- data/lib/ronin/network/mixins/smtp.rb +0 -159
- data/lib/ronin/network/mixins/ssl.rb +0 -148
- data/lib/ronin/network/mixins/tcp.rb +0 -368
- data/lib/ronin/network/mixins/telnet.rb +0 -208
- data/lib/ronin/network/mixins/udp.rb +0 -381
- data/lib/ronin/network/mixins/unix.rb +0 -279
- data/lib/ronin/network/mixins.rb +0 -29
- data/lib/ronin/network/pop3.rb +0 -124
- data/lib/ronin/network/proxy.rb +0 -578
- data/lib/ronin/network/smtp/email.rb +0 -174
- data/lib/ronin/network/smtp/smtp.rb +0 -230
- data/lib/ronin/network/smtp.rb +0 -22
- data/lib/ronin/network/ssl.rb +0 -186
- data/lib/ronin/network/tcp/proxy.rb +0 -417
- data/lib/ronin/network/tcp/tcp.rb +0 -452
- data/lib/ronin/network/tcp.rb +0 -21
- data/lib/ronin/network/telnet.rb +0 -266
- data/lib/ronin/network/udp/proxy.rb +0 -191
- data/lib/ronin/network/udp/udp.rb +0 -452
- data/lib/ronin/network/udp.rb +0 -21
- data/lib/ronin/network/unix.rb +0 -286
- data/lib/ronin/network.rb +0 -31
- data/lib/ronin/path.rb +0 -133
- data/lib/ronin/spec/ui/output.rb +0 -22
- data/lib/ronin/support/inflector.rb +0 -92
- data/lib/ronin/templates/erb.rb +0 -78
- data/lib/ronin/templates/template.rb +0 -169
- data/lib/ronin/templates.rb +0 -21
- data/lib/ronin/ui/output/helpers.rb +0 -296
- data/lib/ronin/ui/output/output.rb +0 -142
- data/lib/ronin/ui/output/terminal/color.rb +0 -124
- data/lib/ronin/ui/output/terminal/raw.rb +0 -103
- data/lib/ronin/ui/output/terminal.rb +0 -21
- data/lib/ronin/ui/output.rb +0 -21
- data/lib/ronin/ui/shell.rb +0 -286
- data/lib/ronin/wordlist.rb +0 -287
- data/spec/binary/hexdump/helpers/hexdumps/ascii.bin +0 -0
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_hex_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_hex_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_octal_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_octal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_repeated.txt +0 -6
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_ints.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_quads.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_ints.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_quads.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_ints.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_quads.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_repeated.txt +0 -6
- data/spec/binary/hexdump/helpers/hexdumps/repeated.bin +0 -1
- data/spec/binary/hexdump/helpers/hexdumps.rb +0 -13
- data/spec/binary/hexdump/parser_spec.rb +0 -302
- data/spec/binary/struct_spec.rb +0 -496
- data/spec/binary/template_spec.rb +0 -416
- data/spec/extensions/enumerable_spec.rb +0 -24
- data/spec/extensions/file_spec.rb +0 -61
- data/spec/extensions/ip_addr_spec.rb +0 -203
- data/spec/extensions/kernel_spec.rb +0 -30
- data/spec/extensions/regexp_spec.rb +0 -482
- data/spec/extensions/resolv_spec.rb +0 -18
- data/spec/extensions/string_spec.rb +0 -180
- data/spec/formatting/binary/array_spec.rb +0 -26
- data/spec/formatting/binary/base64_spec.rb +0 -50
- data/spec/formatting/binary/float_spec.rb +0 -36
- data/spec/formatting/binary/integer_spec.rb +0 -166
- data/spec/formatting/binary/string_spec.rb +0 -199
- data/spec/formatting/digest/string_spec.rb +0 -82
- data/spec/formatting/html/integer_spec.rb +0 -66
- data/spec/formatting/html/string_spec.rb +0 -103
- data/spec/formatting/http/integer_spec.rb +0 -42
- data/spec/formatting/http/string_spec.rb +0 -76
- data/spec/formatting/sql/string_spec.rb +0 -77
- data/spec/formatting/text/array_spec.rb +0 -105
- data/spec/formatting/text/string_spec.rb +0 -162
- data/spec/fuzzing/extensions/string_spec.rb +0 -87
- data/spec/fuzzing/fuzzer_spec.rb +0 -109
- data/spec/fuzzing/fuzzing_spec.rb +0 -24
- data/spec/fuzzing/mutator_spec.rb +0 -112
- data/spec/fuzzing/repeater_spec.rb +0 -57
- data/spec/fuzzing/template_spec.rb +0 -54
- data/spec/mixin_spec.rb +0 -51
- data/spec/network/dns_spec.rb +0 -203
- data/spec/network/ftp_spec.rb +0 -81
- data/spec/network/http/http_spec.rb +0 -559
- data/spec/network/http/proxy_spec.rb +0 -148
- data/spec/network/network_spec.rb +0 -8
- data/spec/network/proxy_spec.rb +0 -121
- data/spec/network/shared/unix_server.rb +0 -31
- data/spec/network/smtp/email_spec.rb +0 -100
- data/spec/network/ssl_spec.rb +0 -70
- data/spec/network/tcp/proxy_spec.rb +0 -118
- data/spec/network/tcp/tcp_spec.rb +0 -316
- data/spec/network/telnet_spec.rb +0 -67
- data/spec/network/udp/udp_spec.rb +0 -298
- data/spec/network/unix_spec.rb +0 -182
- data/spec/path_spec.rb +0 -111
- data/spec/spec_helper.rb +0 -8
- data/spec/support/inflector_spec.rb +0 -22
- data/spec/support_spec.rb +0 -8
- data/spec/templates/classes/example_erb.rb +0 -11
- data/spec/templates/classes/example_template.rb +0 -35
- data/spec/templates/erb_spec.rb +0 -21
- data/spec/templates/helpers/data/includes/_relative.erb +0 -1
- data/spec/templates/helpers/data/templates/example.erb +0 -1
- data/spec/templates/helpers/data.rb +0 -9
- data/spec/templates/template_spec.rb +0 -54
- data/spec/ui/classes/test_shell.rb +0 -22
- data/spec/ui/output_spec.rb +0 -32
- data/spec/ui/shell_spec.rb +0 -83
- data/spec/wordlist_spec.rb +0 -151
@@ -0,0 +1,2582 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
|
+
#
|
5
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published
|
7
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# ronin-support is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'ronin/support/network/http/user_agents'
|
20
|
+
require 'ronin/support/network/http/request'
|
21
|
+
require 'ronin/support/network/http/set_cookie'
|
22
|
+
require 'ronin/support/network/http/core_ext'
|
23
|
+
require 'ronin/support/network/dns/idn'
|
24
|
+
require 'ronin/support/network/ssl'
|
25
|
+
|
26
|
+
require 'net/https'
|
27
|
+
require 'addressable/uri'
|
28
|
+
require 'uri/query_params'
|
29
|
+
|
30
|
+
module Ronin
|
31
|
+
module Support
|
32
|
+
module Network
|
33
|
+
#
|
34
|
+
# Provides helper methods for communicating with HTTP Servers.
|
35
|
+
#
|
36
|
+
# @api public
|
37
|
+
#
|
38
|
+
class HTTP
|
39
|
+
|
40
|
+
#
|
41
|
+
# The Ronin HTTP proxy to use.
|
42
|
+
#
|
43
|
+
# @return [URI::HTTP, Addressable::URI, nil]
|
44
|
+
# The Ronin HTTP proxy.
|
45
|
+
#
|
46
|
+
# @note
|
47
|
+
# If the `RONIN_HTTP_PROXY` environment variable is specified, it
|
48
|
+
# will be used as the default value.
|
49
|
+
# If the `HTTP_PROXY` environment variable is specified, it will
|
50
|
+
# be used as the default value.
|
51
|
+
#
|
52
|
+
# @api public
|
53
|
+
#
|
54
|
+
def self.proxy
|
55
|
+
@proxy ||= if ENV['RONIN_HTTP_PROXY']
|
56
|
+
Addressable::URI.parse(ENV['RONIN_HTTP_PROXY'])
|
57
|
+
elsif ENV['HTTP_PROXY']
|
58
|
+
Addressable::URI.parse(ENV['HTTP_PROXY'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Sets the Ronin HTTP proxy to use.
|
64
|
+
#
|
65
|
+
# @param [URI::HTTP, Addressable::URI, String, nil] new_proxy
|
66
|
+
# The new proxy information to use.
|
67
|
+
#
|
68
|
+
# @return [URI::HTTP, Addressable::URI, nil]
|
69
|
+
# The new proxy.
|
70
|
+
#
|
71
|
+
# @raise [ArgumentError]
|
72
|
+
# The given proxy information was not a `URI::HTTP`,
|
73
|
+
# `Addressable::URI`, `String`, or `nil`.
|
74
|
+
#
|
75
|
+
# @api public
|
76
|
+
#
|
77
|
+
def self.proxy=(new_proxy)
|
78
|
+
@proxy = case new_proxy
|
79
|
+
when URI::HTTP, Addressable::URI
|
80
|
+
new_proxy
|
81
|
+
when String
|
82
|
+
Addressable::URI.parse(new_proxy)
|
83
|
+
when nil
|
84
|
+
nil
|
85
|
+
else
|
86
|
+
raise(ArgumentError,"invalid proxy value (#{new_proxy.inspect}), must be either a URI::HTTP, Addressable::URI, String, or nil")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# The default Ronin HTTP `User-Agent` string.
|
92
|
+
#
|
93
|
+
# @return [String, nil]
|
94
|
+
# The default Ronin HTTP User-Agent.
|
95
|
+
#
|
96
|
+
# @api public
|
97
|
+
#
|
98
|
+
def self.user_agent
|
99
|
+
@user_agent
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Sets the default Ronin HTTP `User-Agent` string.
|
104
|
+
#
|
105
|
+
# @param [String, :random, :chrome, :chrome_linux, :chrome_macos,
|
106
|
+
# :chrome_windows, :chrome_iphone, :chrome_ipad,
|
107
|
+
# :chrome_android, :firefox, :firefox_linux, :firefox_macos,
|
108
|
+
# :firefox_windows, :firefox_iphone, :firefox_ipad,
|
109
|
+
# :firefox_android, :safari, :safari_macos, :safari_iphone,
|
110
|
+
# :safari_ipad, :edge, :linux, :macos, :windows, :iphone,
|
111
|
+
# :ipad, :android, nil] new_user_agent
|
112
|
+
# The new `User-Agent` default value.
|
113
|
+
# * If a `Symbol` or a `String` is given, then the {user_agent}
|
114
|
+
# value will be set.
|
115
|
+
# * If `nil` is given, then the {user_agent} value will be cleared.
|
116
|
+
#
|
117
|
+
# @return [String, nil]
|
118
|
+
# The new `User-Agent` string.
|
119
|
+
#
|
120
|
+
# @api public
|
121
|
+
#
|
122
|
+
def self.user_agent=(new_user_agent)
|
123
|
+
@user_agent = case new_user_agent
|
124
|
+
when Symbol then UserAgents[new_user_agent]
|
125
|
+
else new_user_agent
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# The proxy to send requests through.
|
130
|
+
#
|
131
|
+
# @return [URI::HTTP, Addressable::URI, nil]
|
132
|
+
attr_reader :proxy
|
133
|
+
|
134
|
+
# The host to connect to.
|
135
|
+
#
|
136
|
+
# @return [String]
|
137
|
+
attr_reader :host
|
138
|
+
|
139
|
+
# The port to connect to.
|
140
|
+
#
|
141
|
+
# @return [Integer]
|
142
|
+
attr_reader :port
|
143
|
+
|
144
|
+
# Additional headers to add to every request.
|
145
|
+
#
|
146
|
+
# @return [Hash{String => String,Array}]
|
147
|
+
attr_reader :headers
|
148
|
+
|
149
|
+
# The HTTP Baic-Auth user to add to every request.
|
150
|
+
#
|
151
|
+
# @return [String, nil]
|
152
|
+
attr_reader :user
|
153
|
+
|
154
|
+
# The HTTP Baic-Auth password to add to every request.
|
155
|
+
#
|
156
|
+
# @return [String, nil]
|
157
|
+
attr_reader :password
|
158
|
+
|
159
|
+
# The default cookie params to add to every request.
|
160
|
+
#
|
161
|
+
# @return [Cookie, nil]
|
162
|
+
attr_reader :cookie
|
163
|
+
|
164
|
+
#
|
165
|
+
# @!macro [new] initialize_kwargs
|
166
|
+
# @param [String, URI::HTTP, Addressable::URI, nil] proxy
|
167
|
+
# Optional proxy to use for the request.
|
168
|
+
#
|
169
|
+
# @param [Hash{Symbol,String => String,Array}, nil] headers
|
170
|
+
# Additional headers to add to each request.
|
171
|
+
#
|
172
|
+
# @param [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] user_agent
|
173
|
+
# The default `User-Agent` value to add to each request.
|
174
|
+
#
|
175
|
+
# @param [Cookie, Hash, String, nil] cookie
|
176
|
+
# The default cookie params to add to each request.
|
177
|
+
#
|
178
|
+
# @param [String, nil] user
|
179
|
+
# The HTTP Basic-Auth user to add to each request.
|
180
|
+
#
|
181
|
+
# @param [String, nil] password
|
182
|
+
# The HTTP Basic-Auth password to add to each request.
|
183
|
+
#
|
184
|
+
# @param [Boolean, Hash{Symbol => Object}, nil] ssl
|
185
|
+
# Specifies whether to enable SSL and/or the SSL context
|
186
|
+
# configuration.
|
187
|
+
#
|
188
|
+
# @option ssl [String, nil] :ca_bundle
|
189
|
+
# The path to the CA bundle directory or file.
|
190
|
+
#
|
191
|
+
# @option ssl [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
|
192
|
+
# The certificate to use for the SSL/TLS connection.
|
193
|
+
#
|
194
|
+
# @option ssl [OpenSSL::X509::Store, nil] :cert_store
|
195
|
+
# The certificate store to use for the SSL/TLS connection.
|
196
|
+
#
|
197
|
+
# @option ssl [Array<(name, version, bits, alg_bits)>, nil] :ciphers
|
198
|
+
# The accepted ciphers to use for the SSL/TLS connection.
|
199
|
+
#
|
200
|
+
# @option ssl [Crypto::Cert, OpenSSL::X509::Certificate, nil] :extra_chain_cert
|
201
|
+
# The extra certificate to add to the SSL/TLS certificate chain.
|
202
|
+
#
|
203
|
+
# @option ssl [Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil] :key
|
204
|
+
# The RSA or DSA key to use for the SSL/TLS connection.
|
205
|
+
#
|
206
|
+
# @option ssl [Integer, nil] :timeout
|
207
|
+
# The connection timeout limit.
|
208
|
+
#
|
209
|
+
# @option ssl [1, 1.1, 1.2, Symbol, nil] :version
|
210
|
+
# The desired SSL/TLS version.
|
211
|
+
#
|
212
|
+
# @option ssl [1, 1.1, 1.2, Symbol, nil] :min_version
|
213
|
+
# The minimum SSL/TLS version.
|
214
|
+
#
|
215
|
+
# @option ssl [1, 1.1, 1.2, Symbol, nil] :max_version
|
216
|
+
# The maximum SSL/TLS version.
|
217
|
+
#
|
218
|
+
# @option ssl [Proc, nil] :verify_callback
|
219
|
+
# The callback to use when verifying the server's certificate.
|
220
|
+
#
|
221
|
+
# @option ssl [Integer, nil] :verify_depth
|
222
|
+
# The verification depth limit.
|
223
|
+
#
|
224
|
+
# @option ssl [:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil] :verify
|
225
|
+
# The verification mode.
|
226
|
+
#
|
227
|
+
# @option ssl [Boolean, nil] :verify_hostname
|
228
|
+
# Indicates whether to verify the server's hostname.
|
229
|
+
#
|
230
|
+
|
231
|
+
#
|
232
|
+
# Initializes an HTTP connection.
|
233
|
+
#
|
234
|
+
# @param [String] host
|
235
|
+
# The host to connect to.
|
236
|
+
#
|
237
|
+
# @param [Integer] port
|
238
|
+
# The port to connect tto.
|
239
|
+
#
|
240
|
+
# @!macro initialize_kwargs
|
241
|
+
#
|
242
|
+
# @since 1.0.0
|
243
|
+
#
|
244
|
+
def initialize(host,port, proxy: nil,
|
245
|
+
ssl: port == 443,
|
246
|
+
# header options
|
247
|
+
headers: {},
|
248
|
+
user_agent: self.class.user_agent,
|
249
|
+
cookie: nil,
|
250
|
+
# Basic-Auth options
|
251
|
+
user: nil,
|
252
|
+
password: nil)
|
253
|
+
@host = DNS::IDN.to_ascii(host)
|
254
|
+
@port = port.to_i
|
255
|
+
|
256
|
+
@headers = headers
|
257
|
+
self.user_agent = user_agent if user_agent
|
258
|
+
self.cookie = cookie if cookie
|
259
|
+
|
260
|
+
@user = user
|
261
|
+
@password = password
|
262
|
+
|
263
|
+
if proxy
|
264
|
+
@proxy = URI(proxy)
|
265
|
+
@http = Net::HTTP.new(
|
266
|
+
@host, @port,
|
267
|
+
@proxy.host, @proxy.port, @proxy.user, @proxy.password
|
268
|
+
)
|
269
|
+
else
|
270
|
+
@http = Net::HTTP.new(@host,@port)
|
271
|
+
end
|
272
|
+
|
273
|
+
case ssl
|
274
|
+
when true then initialize_ssl()
|
275
|
+
when Hash then initialize_ssl(**ssl)
|
276
|
+
end
|
277
|
+
|
278
|
+
yield self if block_given?
|
279
|
+
end
|
280
|
+
|
281
|
+
private
|
282
|
+
|
283
|
+
#
|
284
|
+
# Configures an SSL/TLS connection for HTTPS.
|
285
|
+
#
|
286
|
+
# @param [String, nil] ca_bundle
|
287
|
+
# The path to the CA bundle directory or file.
|
288
|
+
#
|
289
|
+
# @param [Crypto::Cert, OpenSSL::X509::Certificate, nil] cert
|
290
|
+
# The certificate to use for the SSL/TLS connection.
|
291
|
+
#
|
292
|
+
# @param [OpenSSL::X509::Store, nil] cert_store
|
293
|
+
# The certificate store to use for the SSL/TLS connection.
|
294
|
+
#
|
295
|
+
# @param [Array<(name, version, bits, alg_bits)>, nil] ciphers
|
296
|
+
# The accepted ciphers to use for the SSL/TLS connection.
|
297
|
+
#
|
298
|
+
# @param [Crypto::Cert,
|
299
|
+
# OpenSSL::X509::Certificate, nil] extra_chain_cert
|
300
|
+
# The extra certificate to add to the SSL/TLS certificate chain.
|
301
|
+
#
|
302
|
+
# @param [Crypto::Key::RSA, Crypto::Key::DSA,
|
303
|
+
# OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil] key
|
304
|
+
# The RSA or DSA key to use for the SSL/TLS connection.
|
305
|
+
#
|
306
|
+
# @param [Integer, nil] timeout
|
307
|
+
# The connection timeout limit.
|
308
|
+
#
|
309
|
+
# @param [1, 1.1, 1.2, Symbol, nil] version
|
310
|
+
# The desired SSL/TLS version.
|
311
|
+
#
|
312
|
+
# @param [1, 1.1, 1.2, Symbol, nil] min_version
|
313
|
+
# The minimum SSL/TLS version.
|
314
|
+
#
|
315
|
+
# @param [1, 1.1, 1.2, Symbol, nil] max_version
|
316
|
+
# The maximum SSL/TLS version.
|
317
|
+
#
|
318
|
+
# @param [Proc, nil] verify_callback
|
319
|
+
# The callback to use when verifying the server's certificate.
|
320
|
+
#
|
321
|
+
# @param [Integer, nil] verify_depth
|
322
|
+
# The verification depth limit.
|
323
|
+
#
|
324
|
+
# @param [:none, :peer, :fail_if_no_peer_cert,
|
325
|
+
# true, false, Integer, nil] verify
|
326
|
+
# The verification mode.
|
327
|
+
#
|
328
|
+
# @param [Boolean, nil] verify_hostname
|
329
|
+
# Indicates whether to verify the server's hostname.
|
330
|
+
#
|
331
|
+
# @api private
|
332
|
+
#
|
333
|
+
def initialize_ssl(ca_bundle: nil,
|
334
|
+
cert: nil,
|
335
|
+
cert_store: nil,
|
336
|
+
ciphers: nil,
|
337
|
+
extra_chain_cert: nil,
|
338
|
+
key: nil,
|
339
|
+
timeout: nil,
|
340
|
+
version: nil,
|
341
|
+
min_version: nil,
|
342
|
+
max_version: nil,
|
343
|
+
verify_callback: nil,
|
344
|
+
verify_depth: nil,
|
345
|
+
verify: :none,
|
346
|
+
verify_hostname: nil)
|
347
|
+
@http.use_ssl = true
|
348
|
+
|
349
|
+
if ca_bundle
|
350
|
+
if File.directory?(ca_bundle)
|
351
|
+
@http.ca_path = ca_bundle
|
352
|
+
else
|
353
|
+
@http.ca_file = ca_file
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
@http.cert = cert if cert
|
358
|
+
@http.ciphers = ciphers if ciphers
|
359
|
+
@http.extra_chain_cert = extra_chain_cert if extra_chain_cert
|
360
|
+
@http.key = key if key
|
361
|
+
|
362
|
+
@http.ssl_timeout = timeout if timeout
|
363
|
+
@http.ssl_version = SSL::VERSIONS.fetch(version,version) if version
|
364
|
+
@http.min_version = min_version if min_version
|
365
|
+
@http.max_version = max_version if max_version
|
366
|
+
|
367
|
+
@http.verify_callback = verify_callback if verify_callback
|
368
|
+
@http.verify_depth = verify_depth if verify_depth
|
369
|
+
@http.verify_mode = SSL::VERIFY.fetch(verify,verify)
|
370
|
+
@http.verify_hostname = verify_hostname if verify_hostname
|
371
|
+
end
|
372
|
+
|
373
|
+
public
|
374
|
+
|
375
|
+
#
|
376
|
+
# @!macro connect_kwargs
|
377
|
+
# @param [Boolean, Hash{Symbol => Object}, nil] ssl
|
378
|
+
# Specifies whether to enable SSL and/or the SSL context
|
379
|
+
# configuration.
|
380
|
+
#
|
381
|
+
# @param [Hash{Symbol => Object}] kwargs
|
382
|
+
# Additional keyword arguments for {#initialize}.
|
383
|
+
#
|
384
|
+
# @option kwargs [String, URI::HTTP, Addressable::URI, nil] :proxy
|
385
|
+
# The optional proxy to send requests through.
|
386
|
+
#
|
387
|
+
# @option kwargs [Hash{Symbol,String => String,Array}, nil] :headers
|
388
|
+
# Additional headers to add to each request.
|
389
|
+
#
|
390
|
+
# @option kwargs [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] :user_agent (HTTP.user_agent)
|
391
|
+
# The default `User-Agent` string to add to each request.
|
392
|
+
#
|
393
|
+
# @option kwargs [String, nil] :user
|
394
|
+
# The HTTP Basic-Auth user to add to each request.
|
395
|
+
#
|
396
|
+
# @option kwargs [String, nil] :password
|
397
|
+
# The HTTP Basic-Auth password to add to each request.
|
398
|
+
#
|
399
|
+
# @option ssl [String, nil] :ca_bundle
|
400
|
+
# The path to the CA bundle directory or file.
|
401
|
+
#
|
402
|
+
# @option ssl [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
|
403
|
+
# The certificate to use for the SSL/TLS connection.
|
404
|
+
#
|
405
|
+
# @option ssl [OpenSSL::X509::Store, nil] :cert_store
|
406
|
+
# The certificate store to use for the SSL/TLS connection.
|
407
|
+
#
|
408
|
+
# @option ssl [Array<(name, version, bits, alg_bits)>, nil] :ciphers
|
409
|
+
# The accepted ciphers to use for the SSL/TLS connection.
|
410
|
+
#
|
411
|
+
# @option ssl [Crypto::Cert, OpenSSL::X509::Certificate, nil] :extra_chain_cert
|
412
|
+
# The extra certificate to add to the SSL/TLS certificate chain.
|
413
|
+
#
|
414
|
+
# @option ssl [Crypto::Key::RSA, Crypto::Key::DSA, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA, nil] :key
|
415
|
+
# The RSA or DSA key to use for the SSL/TLS connection.
|
416
|
+
#
|
417
|
+
# @option ssl [Integer, nil] :timeout
|
418
|
+
# The connection timeout limit.
|
419
|
+
#
|
420
|
+
# @option ssl [1, 1.1, 1.2, Symbol, nil] :version
|
421
|
+
# The desired SSL/TLS version.
|
422
|
+
#
|
423
|
+
# @option ssl [1, 1.1, 1.2, Symbol, nil] :min_version
|
424
|
+
# The minimum SSL/TLS version.
|
425
|
+
#
|
426
|
+
# @option ssl [1, 1.1, 1.2, Symbol, nil] :max_version
|
427
|
+
# The maximum SSL/TLS version.
|
428
|
+
#
|
429
|
+
# @option ssl [Proc, nil] :verify_callback
|
430
|
+
# The callback to use when verifying the server's certificate.
|
431
|
+
#
|
432
|
+
# @option ssl [Integer, nil] :verify_depth
|
433
|
+
# The verification depth limit.
|
434
|
+
#
|
435
|
+
# @option ssl [:none, :peer, :fail_if_no_peer_cert, true, false, Integer, nil] :verify
|
436
|
+
# The verification mode.
|
437
|
+
#
|
438
|
+
# @option ssl [Boolean, nil] :verify_hostname
|
439
|
+
# Indicates whether to verify the server's hostname.
|
440
|
+
#
|
441
|
+
|
442
|
+
#
|
443
|
+
# Creates a HTTP connection to the host nad port.
|
444
|
+
#
|
445
|
+
# @param [String] host
|
446
|
+
# The host to connect to.
|
447
|
+
#
|
448
|
+
# @param [Integer] port
|
449
|
+
# The port to connect to.
|
450
|
+
#
|
451
|
+
# @!macro connect_kwargs
|
452
|
+
#
|
453
|
+
# @yield [http]
|
454
|
+
# If a block is given, it will be passed the newly created HTTP
|
455
|
+
# session object. Once the block returns, the HTTP session will be
|
456
|
+
# closed.
|
457
|
+
#
|
458
|
+
# @yieldparam [HTTP] http
|
459
|
+
# The HTTP session object.
|
460
|
+
#
|
461
|
+
# @return [HTTP, nil]
|
462
|
+
# The HTTP session object. If a block is given, then `nil` will be
|
463
|
+
# returned.
|
464
|
+
#
|
465
|
+
# @since 1.0.0
|
466
|
+
#
|
467
|
+
def self.connect(host,port, ssl: port == 443, **kwargs)
|
468
|
+
http = new(host,port, ssl: ssl, **kwargs)
|
469
|
+
|
470
|
+
if block_given?
|
471
|
+
yield http
|
472
|
+
http.close
|
473
|
+
else
|
474
|
+
return http
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
#
|
479
|
+
# Creates a HTTP connection using the URI.
|
480
|
+
#
|
481
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
482
|
+
# The URI to connect to.
|
483
|
+
#
|
484
|
+
# @!macro connect_kwargs
|
485
|
+
#
|
486
|
+
# @yield [http]
|
487
|
+
# If a block is given, it will be passed the newly created HTTP
|
488
|
+
# session object. Once the block returns, the HTTP session will be
|
489
|
+
# closed.
|
490
|
+
#
|
491
|
+
# @yieldparam [HTTP] http
|
492
|
+
# The HTTP session object.
|
493
|
+
#
|
494
|
+
# @return [HTTP, nil]
|
495
|
+
# The HTTP session object. If a block is given, then `nil` will be
|
496
|
+
# returned.
|
497
|
+
#
|
498
|
+
# @raise [ArgumentError]
|
499
|
+
# The URL was not a URI::HTTP, Addressable::URI, or a String object.
|
500
|
+
#
|
501
|
+
# @since 1.0.0
|
502
|
+
#
|
503
|
+
def self.connect_uri(url, ssl: nil, **kwargs,&block)
|
504
|
+
uri = case url
|
505
|
+
when Addressable::URI, URI::HTTP
|
506
|
+
url
|
507
|
+
when String
|
508
|
+
Addressable::URI.parse(url)
|
509
|
+
else
|
510
|
+
raise(ArgumentError,"url must be a URI::HTTP, Addressable::URI, or a String: #{url.inspect}")
|
511
|
+
end
|
512
|
+
|
513
|
+
host = uri.host
|
514
|
+
port = uri.port
|
515
|
+
ssl ||= uri.scheme == 'https'
|
516
|
+
|
517
|
+
return connect(host,port, ssl: ssl, **kwargs,&block)
|
518
|
+
end
|
519
|
+
|
520
|
+
#
|
521
|
+
# Determines if the HTTP connect is using SSL/TLS.
|
522
|
+
#
|
523
|
+
# @return [Boolean]
|
524
|
+
#
|
525
|
+
# @since 1.0.0
|
526
|
+
#
|
527
|
+
def ssl?
|
528
|
+
@http.use_ssl?
|
529
|
+
end
|
530
|
+
|
531
|
+
#
|
532
|
+
# The `User-Agent` header value.
|
533
|
+
#
|
534
|
+
# @return [String, nil]
|
535
|
+
#
|
536
|
+
# @since 1.0.0
|
537
|
+
#
|
538
|
+
attr_reader :user_agent
|
539
|
+
|
540
|
+
#
|
541
|
+
# Sets the `User-Agent` header value.
|
542
|
+
#
|
543
|
+
# @param [String, :random, :chrome, :chrome_linux, :chrome_macos,
|
544
|
+
# :chrome_windows, :chrome_iphone, :chrome_ipad,
|
545
|
+
# :chrome_android, :firefox, :firefox_linux, :firefox_macos,
|
546
|
+
# :firefox_windows, :firefox_iphone, :firefox_ipad,
|
547
|
+
# :firefox_android, :safari, :safari_macos, :safari_iphone,
|
548
|
+
# :safari_ipad, :edge, :linux, :macos, :windows, :iphone,
|
549
|
+
# :ipad, :android, nil] new_user_agent
|
550
|
+
# The new `User-Agent` default value.
|
551
|
+
# * If a `Symbol` or a `String` is given, then the `User-Agent`
|
552
|
+
# header will be set.
|
553
|
+
# * If `nil` is given, then the `User-Agent` header will be deleted.
|
554
|
+
#
|
555
|
+
# @return [String, nil]
|
556
|
+
# The new `User-Agent` string.
|
557
|
+
#
|
558
|
+
# @since 1.0.0
|
559
|
+
#
|
560
|
+
def user_agent=(new_user_agent)
|
561
|
+
@user_agent = case new_user_agent
|
562
|
+
when Symbol then UserAgents[new_user_agent]
|
563
|
+
else new_user_agent
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
567
|
+
#
|
568
|
+
# Sets the default cookie value.
|
569
|
+
#
|
570
|
+
# @param [Cookie, Hash, String, nil] new_cookie
|
571
|
+
# The new cookie value to set.
|
572
|
+
#
|
573
|
+
# @return [Cookie, nil]
|
574
|
+
# The new default cookie value.
|
575
|
+
#
|
576
|
+
# @raise [ArgumentError]
|
577
|
+
# The new cookie value must be a {Cookie}, Hash, String, or nil.
|
578
|
+
#
|
579
|
+
# @since 1.0.0
|
580
|
+
#
|
581
|
+
def cookie=(new_cookie)
|
582
|
+
@cookie = case new_cookie
|
583
|
+
when Cookie then new_cookie
|
584
|
+
when Hash then Cookie.new(new_cookie)
|
585
|
+
when String then Cookie.parse(new_cookie)
|
586
|
+
when nil then nil
|
587
|
+
else
|
588
|
+
raise(ArgumentError,"cookie value must be a #{Cookie}, Hash, String, or nil: #{new_cookie.inspect}")
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
#
|
593
|
+
# Sends an arbitrary HTTP request.
|
594
|
+
#
|
595
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
596
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
597
|
+
# :trace, :unlock] method
|
598
|
+
# The HTTP method to use for the request.
|
599
|
+
#
|
600
|
+
# @param [String] path
|
601
|
+
# The path to to make the request for.
|
602
|
+
#
|
603
|
+
# @param [String, nil] query
|
604
|
+
# The query-string to append to the request path.
|
605
|
+
#
|
606
|
+
# @param [Hash, nil] query_params
|
607
|
+
# The query-params to append to the request path.
|
608
|
+
#
|
609
|
+
# @param [String, nil] user
|
610
|
+
# The user to authenticate as.
|
611
|
+
#
|
612
|
+
# @param [String, nil] password
|
613
|
+
# The password to authenticate with.
|
614
|
+
#
|
615
|
+
# @param [Hash{Symbol,String => String}, nil] headers
|
616
|
+
# Additional HTTP header names and values to add to the request.
|
617
|
+
#
|
618
|
+
# @param [String, Hash{String => String}, nil] cookie
|
619
|
+
# Additional `Cookie` header. If a `Hash` is given, it will be
|
620
|
+
# converted to a `String` using {Cookie}.
|
621
|
+
#
|
622
|
+
# @param [String, nil] body
|
623
|
+
# The body of the request.
|
624
|
+
#
|
625
|
+
# @param [Hash, String, nil] form_data
|
626
|
+
# The form data that may be sent in the body of the request.
|
627
|
+
#
|
628
|
+
# @param [Hash{Symbol => String}] additional_headers
|
629
|
+
# Additional headers to add to the request.
|
630
|
+
#
|
631
|
+
# @yield [response]
|
632
|
+
# If a block is given it will be passed the received HTTP response.
|
633
|
+
#
|
634
|
+
# @yieldparam [Net::HTTPResponse] response
|
635
|
+
# The received HTTP response object.
|
636
|
+
#
|
637
|
+
# @return [Net::HTTPResponse]
|
638
|
+
# The new HTTP Request object.
|
639
|
+
#
|
640
|
+
# @raise [ArgumentError]
|
641
|
+
# The `:method` option did not match a known `Net::HTTP` request
|
642
|
+
# class.
|
643
|
+
#
|
644
|
+
# @example
|
645
|
+
# http.request(:get, '/')
|
646
|
+
#
|
647
|
+
# @example Streaming response body:
|
648
|
+
# http.request(:get, '/big_file.txt') do |response|
|
649
|
+
# respnse.read_body do |chunk|
|
650
|
+
# # ...
|
651
|
+
# end
|
652
|
+
# end
|
653
|
+
#
|
654
|
+
# @example Basic-Auth
|
655
|
+
# http.request(:get, '/', user: 'admin', password: 'secret')
|
656
|
+
#
|
657
|
+
# @example Query string:
|
658
|
+
# http.request(:get, '/search', query: 'foo%20bar')
|
659
|
+
#
|
660
|
+
# @example Query params:
|
661
|
+
# http.request(:get, '/search', query_params: {q: 'foo bar'})
|
662
|
+
#
|
663
|
+
# @example Request body:
|
664
|
+
# http.request(:post, '/form', body: 'foo=1&bar=2')
|
665
|
+
#
|
666
|
+
# @example Form data:
|
667
|
+
# http.request(:post, '/form', form_data: {'foo' => 1, 'bar' => 2})
|
668
|
+
#
|
669
|
+
# @example Streaming request body:
|
670
|
+
# http.request(:put, '/file', body: File.new('/path/to/file'))
|
671
|
+
#
|
672
|
+
# @since 1.0.0
|
673
|
+
#
|
674
|
+
def request(method,path, # query string keyword arguments
|
675
|
+
query: nil,
|
676
|
+
query_params: nil,
|
677
|
+
# header keyword arguments
|
678
|
+
headers: nil,
|
679
|
+
user_agent: @user_agent,
|
680
|
+
cookie: @cookie,
|
681
|
+
# Basic-Auth keyword arguments
|
682
|
+
user: @user,
|
683
|
+
password: @password,
|
684
|
+
# request body keyword arguments
|
685
|
+
body: nil,
|
686
|
+
form_data: nil,
|
687
|
+
**additional_headers,
|
688
|
+
&block)
|
689
|
+
request = Request.build(method,path, headers: @headers,
|
690
|
+
user_agent: user_agent,
|
691
|
+
cookie: cookie,
|
692
|
+
user: user,
|
693
|
+
password: password,
|
694
|
+
query: query,
|
695
|
+
query_params: query_params,
|
696
|
+
body: body,
|
697
|
+
form_data: form_data)
|
698
|
+
|
699
|
+
if headers
|
700
|
+
# populate any arbitrary headers
|
701
|
+
headers.each do |name,value|
|
702
|
+
request[name] = value
|
703
|
+
end
|
704
|
+
end
|
705
|
+
|
706
|
+
unless additional_headers.empty?
|
707
|
+
# set additional keyword argument headers (ex: `referer: '...'`
|
708
|
+
additional_headers.each do |name,value|
|
709
|
+
request[name] = value
|
710
|
+
end
|
711
|
+
end
|
712
|
+
|
713
|
+
return @http.request(request,&block)
|
714
|
+
end
|
715
|
+
|
716
|
+
#
|
717
|
+
# @!macro request_kwargs
|
718
|
+
# @param [Hash{Symbol => Object}] kwargs
|
719
|
+
# Aditional keyword arguments and headers for {#request}.
|
720
|
+
#
|
721
|
+
# @option kwargs [String, nil] :query
|
722
|
+
# The query-string to append to the request path.
|
723
|
+
#
|
724
|
+
# @option kwargs [Hash, nil] :query_params
|
725
|
+
# The query-params to append to the request path.
|
726
|
+
#
|
727
|
+
# @option kwargs [String, nil] :user
|
728
|
+
# The user to authenticate as.
|
729
|
+
#
|
730
|
+
# @option kwargs [String, nil] :password
|
731
|
+
# The password to authenticate with.
|
732
|
+
#
|
733
|
+
# @option kwargs [Hash{Symbol,String => String}, nil] :headers
|
734
|
+
# Additional HTTP header names and values to add to the request.
|
735
|
+
#
|
736
|
+
# @option kwargs [String, Hash{String => String}, Cookie, nil] :cookie
|
737
|
+
# Additional `Cookie` header. If a `Hash` is given, it will be
|
738
|
+
# converted to a `String` using {Cookie}. If the cookie value is
|
739
|
+
# empty, the `Cookie` header will not be set.
|
740
|
+
#
|
741
|
+
# @option kwargs [String, nil] :body
|
742
|
+
# The body of the request.
|
743
|
+
#
|
744
|
+
# @option kwargs [Hash, String, nil] :form_data
|
745
|
+
# The form data that may be sent in the body of the request.
|
746
|
+
#
|
747
|
+
|
748
|
+
#
|
749
|
+
# Sends an arbitrary HTTP request and returns the response status.
|
750
|
+
#
|
751
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
752
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
753
|
+
# :trace, :unlock] method
|
754
|
+
# The HTTP method to use for the request.
|
755
|
+
#
|
756
|
+
# @param [String] path
|
757
|
+
# The path to to make the request for.
|
758
|
+
#
|
759
|
+
# @!macro request_kwargs
|
760
|
+
#
|
761
|
+
# @return [Integer]
|
762
|
+
# The response status code.
|
763
|
+
#
|
764
|
+
# @since 1.0.0
|
765
|
+
#
|
766
|
+
def response_status(method=:head,path,**kwargs)
|
767
|
+
response = request(method,path,**kwargs)
|
768
|
+
response.code.to_i
|
769
|
+
end
|
770
|
+
|
771
|
+
#
|
772
|
+
# Sends a HTTP request and determines if the response status was 200.
|
773
|
+
#
|
774
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
775
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
776
|
+
# :trace, :unlock] method
|
777
|
+
# The HTTP method to use for the request.
|
778
|
+
#
|
779
|
+
# @param [String] path
|
780
|
+
# The path to to make the request for.
|
781
|
+
#
|
782
|
+
# @!macro request_kwargs
|
783
|
+
#
|
784
|
+
# @return [Boolean]
|
785
|
+
# Indicates that the response status was 200.
|
786
|
+
#
|
787
|
+
# @since 1.0.0
|
788
|
+
#
|
789
|
+
def ok?(method=:head,path,**kwargs)
|
790
|
+
response_status(method,path,**kwargs) == 200
|
791
|
+
end
|
792
|
+
|
793
|
+
#
|
794
|
+
# Sends an arbitrary HTTP request and returns the response headers.
|
795
|
+
#
|
796
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
797
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
798
|
+
# :trace, :unlock] method
|
799
|
+
# The HTTP method to use for the request.
|
800
|
+
#
|
801
|
+
# @param [String] path
|
802
|
+
# The path to to make the request for.
|
803
|
+
#
|
804
|
+
# @!macro request_kwargs
|
805
|
+
#
|
806
|
+
# @return [Hash{String => String}]
|
807
|
+
# The response headers.
|
808
|
+
#
|
809
|
+
# @since 1.0.0
|
810
|
+
#
|
811
|
+
def response_headers(method=:head,path,**kwargs)
|
812
|
+
headers = {}
|
813
|
+
|
814
|
+
request(method,path,**kwargs).each_capitalized do |name,value|
|
815
|
+
headers[name] = value
|
816
|
+
end
|
817
|
+
|
818
|
+
return headers
|
819
|
+
end
|
820
|
+
|
821
|
+
#
|
822
|
+
# Sends an HTTP request and returns the `Server` header.
|
823
|
+
#
|
824
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
825
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
826
|
+
# :trace, :unlock] method
|
827
|
+
# The HTTP method to use for the request.
|
828
|
+
#
|
829
|
+
# @param [String] path
|
830
|
+
# The path to to make the request for.
|
831
|
+
#
|
832
|
+
# @!macro request_kwargs
|
833
|
+
#
|
834
|
+
# @return [String, nil]
|
835
|
+
# The `Server` header.
|
836
|
+
#
|
837
|
+
# @since 1.0.0
|
838
|
+
#
|
839
|
+
def server_header(method: :head, path: '/',**kwargs)
|
840
|
+
response = request(method,path,**kwargs)
|
841
|
+
response['Server']
|
842
|
+
end
|
843
|
+
|
844
|
+
#
|
845
|
+
# Sends an HTTP request and returns the `X-Powered-By` header.
|
846
|
+
#
|
847
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
848
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
849
|
+
# :trace, :unlock] method
|
850
|
+
# The HTTP method to use for the request.
|
851
|
+
#
|
852
|
+
# @param [String] path
|
853
|
+
# The path to to make the request for.
|
854
|
+
#
|
855
|
+
# @!macro request_kwargs
|
856
|
+
#
|
857
|
+
# @return [String, nil]
|
858
|
+
# The `X-Powered-By` header.
|
859
|
+
#
|
860
|
+
# @since 1.0.0
|
861
|
+
#
|
862
|
+
def powered_by_header(method: :head, path: '/',**kwargs)
|
863
|
+
response = request(method,path,**kwargs)
|
864
|
+
response['X-Powered-By']
|
865
|
+
end
|
866
|
+
|
867
|
+
#
|
868
|
+
# Sends an arbitrary HTTP request and returns the response body.
|
869
|
+
#
|
870
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
871
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
872
|
+
# :trace, :unlock] method
|
873
|
+
# The HTTP method to use for the request.
|
874
|
+
#
|
875
|
+
# @param [String] path
|
876
|
+
# The path to to make the request for.
|
877
|
+
#
|
878
|
+
# @!macro request_kwargs
|
879
|
+
#
|
880
|
+
# @return [String]
|
881
|
+
# The response body.
|
882
|
+
#
|
883
|
+
# @since 1.0.0
|
884
|
+
#
|
885
|
+
def response_body(method=:get,path,**kwargs)
|
886
|
+
request(method,path,**kwargs).body
|
887
|
+
end
|
888
|
+
|
889
|
+
#
|
890
|
+
# Sends a `COPY` HTTP request.
|
891
|
+
#
|
892
|
+
# @param [String] path
|
893
|
+
# The path to to make the request for.
|
894
|
+
#
|
895
|
+
# @!macro request_kwargs
|
896
|
+
#
|
897
|
+
# @yield [response]
|
898
|
+
# If a block is given it will be passed the received HTTP response.
|
899
|
+
#
|
900
|
+
# @yieldparam [Net::HTTPResponse] response
|
901
|
+
# The received HTTP response object.
|
902
|
+
#
|
903
|
+
# @return [Net::HTTPResponse]
|
904
|
+
# The new HTTP Request object.
|
905
|
+
#
|
906
|
+
# @since 1.0.0
|
907
|
+
#
|
908
|
+
def copy(path,**kwargs,&block)
|
909
|
+
request(:copy,path,**kwargs,&block)
|
910
|
+
end
|
911
|
+
|
912
|
+
#
|
913
|
+
# Sends a `DELETE` HTTP request.
|
914
|
+
#
|
915
|
+
# @param [String] path
|
916
|
+
# The path to to make the request for.
|
917
|
+
#
|
918
|
+
# @!macro request_kwargs
|
919
|
+
#
|
920
|
+
# @yield [response]
|
921
|
+
# If a block is given it will be passed the received HTTP response.
|
922
|
+
#
|
923
|
+
# @yieldparam [Net::HTTPResponse] response
|
924
|
+
# The received HTTP response object.
|
925
|
+
#
|
926
|
+
# @return [Net::HTTPResponse]
|
927
|
+
# The new HTTP Request object.
|
928
|
+
#
|
929
|
+
# @since 1.0.0
|
930
|
+
#
|
931
|
+
def delete(path,**kwargs,&block)
|
932
|
+
request(:delete,path,**kwargs,&block)
|
933
|
+
end
|
934
|
+
|
935
|
+
#
|
936
|
+
# Sends a `GET` HTTP request.
|
937
|
+
#
|
938
|
+
# @param [String] path
|
939
|
+
# The path to to make the request for.
|
940
|
+
#
|
941
|
+
# @!macro request_kwargs
|
942
|
+
#
|
943
|
+
# @yield [response]
|
944
|
+
# If a block is given it will be passed the received HTTP response.
|
945
|
+
#
|
946
|
+
# @yieldparam [Net::HTTPResponse] response
|
947
|
+
# The received HTTP response object.
|
948
|
+
#
|
949
|
+
# @return [Net::HTTPResponse]
|
950
|
+
# The new HTTP Request object.
|
951
|
+
#
|
952
|
+
# @since 1.0.0
|
953
|
+
#
|
954
|
+
def get(path,**kwargs,&block)
|
955
|
+
request(:get,path,**kwargs,&block)
|
956
|
+
end
|
957
|
+
|
958
|
+
#
|
959
|
+
# Sends a `GET` HTTP request and returns the response headers.
|
960
|
+
#
|
961
|
+
# @param [String] path
|
962
|
+
# The path to to make the request for.
|
963
|
+
#
|
964
|
+
# @!macro request_kwargs
|
965
|
+
#
|
966
|
+
# @return [Hash{String => String}]
|
967
|
+
# The response headers.
|
968
|
+
#
|
969
|
+
# @since 1.0.0
|
970
|
+
#
|
971
|
+
def get_headers(path,**kwargs)
|
972
|
+
response_headers(:get,path,**kwargs)
|
973
|
+
end
|
974
|
+
|
975
|
+
#
|
976
|
+
# Sends an HTTP request and returns the parsed `Set-Cookie` header(s).
|
977
|
+
#
|
978
|
+
# @param [String] path
|
979
|
+
# The path to to make the request for.
|
980
|
+
#
|
981
|
+
# @!macro request_kwargs
|
982
|
+
#
|
983
|
+
# @return [Array<SetCookie>]
|
984
|
+
# The parsed `Set-Cookie` headers.
|
985
|
+
#
|
986
|
+
# @since 1.0.0
|
987
|
+
#
|
988
|
+
def get_cookies(path, **kwargs)
|
989
|
+
response = request(:get,path,**kwargs)
|
990
|
+
|
991
|
+
if (set_cookies = response.get_fields('Set-Cookie'))
|
992
|
+
set_cookies.map do |cookie|
|
993
|
+
SetCookie.parse(cookie)
|
994
|
+
end
|
995
|
+
else
|
996
|
+
[]
|
997
|
+
end
|
998
|
+
end
|
999
|
+
|
1000
|
+
#
|
1001
|
+
# Sends a `GET` HTTP request and returns the response body.
|
1002
|
+
#
|
1003
|
+
# @param [String] path
|
1004
|
+
# The path to to make the request for.
|
1005
|
+
#
|
1006
|
+
# @!macro request_kwargs
|
1007
|
+
#
|
1008
|
+
# @return [String]
|
1009
|
+
# The response body.
|
1010
|
+
#
|
1011
|
+
# @since 1.0.0
|
1012
|
+
#
|
1013
|
+
def get_body(path,**kwargs)
|
1014
|
+
response_body(:get,path,**kwargs)
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
#
|
1018
|
+
# Sends a `HEAD` HTTP request.
|
1019
|
+
#
|
1020
|
+
# @param [String] path
|
1021
|
+
# The path to to make the request for.
|
1022
|
+
#
|
1023
|
+
# @!macro request_kwargs
|
1024
|
+
#
|
1025
|
+
# @yield [response]
|
1026
|
+
# If a block is given it will be passed the received HTTP response.
|
1027
|
+
#
|
1028
|
+
# @yieldparam [Net::HTTPResponse] response
|
1029
|
+
# The received HTTP response object.
|
1030
|
+
#
|
1031
|
+
# @return [Net::HTTPResponse]
|
1032
|
+
# The new HTTP Request object.
|
1033
|
+
#
|
1034
|
+
# @since 1.0.0
|
1035
|
+
#
|
1036
|
+
def head(path,**kwargs,&block)
|
1037
|
+
request(:head,path,**kwargs,&block)
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
#
|
1041
|
+
# Sends a `LOCK` HTTP request.
|
1042
|
+
#
|
1043
|
+
# @param [String] path
|
1044
|
+
# The path to to make the request for.
|
1045
|
+
#
|
1046
|
+
# @!macro request_kwargs
|
1047
|
+
#
|
1048
|
+
# @yield [response]
|
1049
|
+
# If a block is given it will be passed the received HTTP response.
|
1050
|
+
#
|
1051
|
+
# @yieldparam [Net::HTTPResponse] response
|
1052
|
+
# The received HTTP response object.
|
1053
|
+
#
|
1054
|
+
# @return [Net::HTTPResponse]
|
1055
|
+
# The new HTTP Request object.
|
1056
|
+
#
|
1057
|
+
# @since 1.0.0
|
1058
|
+
#
|
1059
|
+
def lock(path,**kwargs,&block)
|
1060
|
+
request(:lock,path,**kwargs,&block)
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
#
|
1064
|
+
# Sends a `MKCOL` HTTP request.
|
1065
|
+
#
|
1066
|
+
# @param [String] path
|
1067
|
+
# The path to to make the request for.
|
1068
|
+
#
|
1069
|
+
# @!macro request_kwargs
|
1070
|
+
#
|
1071
|
+
# @yield [response]
|
1072
|
+
# If a block is given it will be passed the received HTTP response.
|
1073
|
+
#
|
1074
|
+
# @yieldparam [Net::HTTPResponse] response
|
1075
|
+
# The received HTTP response object.
|
1076
|
+
#
|
1077
|
+
# @return [Net::HTTPResponse]
|
1078
|
+
# The new HTTP Request object.
|
1079
|
+
#
|
1080
|
+
# @since 1.0.0
|
1081
|
+
#
|
1082
|
+
def mkcol(path,**kwargs,&block)
|
1083
|
+
request(:mkcol,path,**kwargs,&block)
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
#
|
1087
|
+
# Sends a `MOVE` HTTP request.
|
1088
|
+
#
|
1089
|
+
# @param [String] path
|
1090
|
+
# The path to to make the request for.
|
1091
|
+
#
|
1092
|
+
# @!macro request_kwargs
|
1093
|
+
#
|
1094
|
+
# @yield [response]
|
1095
|
+
# If a block is given it will be passed the received HTTP response.
|
1096
|
+
#
|
1097
|
+
# @yieldparam [Net::HTTPResponse] response
|
1098
|
+
# The received HTTP response object.
|
1099
|
+
#
|
1100
|
+
# @return [Net::HTTPResponse]
|
1101
|
+
# The new HTTP Request object.
|
1102
|
+
#
|
1103
|
+
# @since 1.0.0
|
1104
|
+
#
|
1105
|
+
def move(path,**kwargs,&block)
|
1106
|
+
request(:move,path,**kwargs,&block)
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
#
|
1110
|
+
# Sends a `OPTIONS` HTTP request.
|
1111
|
+
#
|
1112
|
+
# @param [String] path
|
1113
|
+
# The path to to make the request for.
|
1114
|
+
#
|
1115
|
+
# @!macro request_kwargs
|
1116
|
+
#
|
1117
|
+
# @yield [response]
|
1118
|
+
# If a block is given it will be passed the received HTTP response.
|
1119
|
+
#
|
1120
|
+
# @yieldparam [Net::HTTPResponse] response
|
1121
|
+
# The received HTTP response object.
|
1122
|
+
#
|
1123
|
+
# @return [Net::HTTPResponse]
|
1124
|
+
# The new HTTP Request object.
|
1125
|
+
#
|
1126
|
+
# @since 1.0.0
|
1127
|
+
#
|
1128
|
+
def options(path,**kwargs,&block)
|
1129
|
+
request(:options,path,**kwargs,&block)
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
#
|
1133
|
+
# Sends a `OPTIONS` HTTP request and parses the `Allow` response
|
1134
|
+
# header.
|
1135
|
+
#
|
1136
|
+
# @param [String] path
|
1137
|
+
# The path to to make the request for.
|
1138
|
+
#
|
1139
|
+
# @!macro request_kwargs
|
1140
|
+
#
|
1141
|
+
# @return [Array<Symbol>]
|
1142
|
+
# The allowed HTTP request methods for the given path.
|
1143
|
+
#
|
1144
|
+
# @since 1.0.0
|
1145
|
+
#
|
1146
|
+
def allowed_methods(path='*',**kwargs)
|
1147
|
+
response = options(path,**kwargs)
|
1148
|
+
allow = response['Allow']
|
1149
|
+
methods = allow.split(', ')
|
1150
|
+
|
1151
|
+
methods.map! do |method|
|
1152
|
+
method.downcase!
|
1153
|
+
method.to_sym
|
1154
|
+
end
|
1155
|
+
|
1156
|
+
return methods
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
#
|
1160
|
+
# Sends a `PATCH` HTTP request.
|
1161
|
+
#
|
1162
|
+
# @param [String] path
|
1163
|
+
# The path to to make the request for.
|
1164
|
+
#
|
1165
|
+
# @!macro request_kwargs
|
1166
|
+
#
|
1167
|
+
# @yield [response]
|
1168
|
+
# If a block is given it will be passed the received HTTP response.
|
1169
|
+
#
|
1170
|
+
# @yieldparam [Net::HTTPResponse] response
|
1171
|
+
# The received HTTP response object.
|
1172
|
+
#
|
1173
|
+
# @return [Net::HTTPResponse]
|
1174
|
+
# The new HTTP Request object.
|
1175
|
+
#
|
1176
|
+
# @since 1.0.0
|
1177
|
+
#
|
1178
|
+
def patch(path,**kwargs,&block)
|
1179
|
+
request(:patch,path,**kwargs,&block)
|
1180
|
+
end
|
1181
|
+
|
1182
|
+
#
|
1183
|
+
# Sends a `POST` HTTP request.
|
1184
|
+
#
|
1185
|
+
# @param [String] path
|
1186
|
+
# The path to to make the request for.
|
1187
|
+
#
|
1188
|
+
# @!macro request_kwargs
|
1189
|
+
#
|
1190
|
+
# @yield [response]
|
1191
|
+
# If a block is given it will be passed the received HTTP response.
|
1192
|
+
#
|
1193
|
+
# @yieldparam [Net::HTTPResponse] response
|
1194
|
+
# The received HTTP response object.
|
1195
|
+
#
|
1196
|
+
# @return [Net::HTTPResponse]
|
1197
|
+
# The new HTTP Request object.
|
1198
|
+
#
|
1199
|
+
# @since 1.0.0
|
1200
|
+
#
|
1201
|
+
def post(path,**kwargs,&block)
|
1202
|
+
request(:post,path,**kwargs,&block)
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
#
|
1206
|
+
# Sends a `POST` HTTP request and returns the response headers.
|
1207
|
+
#
|
1208
|
+
# @param [String] path
|
1209
|
+
# The path to to make the request for.
|
1210
|
+
#
|
1211
|
+
# @!macro request_kwargs
|
1212
|
+
#
|
1213
|
+
# @return [Hash{String => String}]
|
1214
|
+
# The response headers.
|
1215
|
+
#
|
1216
|
+
# @since 1.0.0
|
1217
|
+
#
|
1218
|
+
def post_headers(path,**kwargs)
|
1219
|
+
response_headers(:post,path,**kwargs)
|
1220
|
+
end
|
1221
|
+
|
1222
|
+
#
|
1223
|
+
# Sends a `POST` HTTP request and returns the response body.
|
1224
|
+
#
|
1225
|
+
# @param [String] path
|
1226
|
+
# The path to to make the request for.
|
1227
|
+
#
|
1228
|
+
# @!macro request_kwargs
|
1229
|
+
#
|
1230
|
+
# @return [String]
|
1231
|
+
# The response body.
|
1232
|
+
#
|
1233
|
+
# @since 1.0.0
|
1234
|
+
#
|
1235
|
+
def post_body(path,**kwargs)
|
1236
|
+
response_body(:post,path,**kwargs)
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
#
|
1240
|
+
# Sends a `PROPFIND` HTTP request.
|
1241
|
+
#
|
1242
|
+
# @param [String] path
|
1243
|
+
# The path to to make the request for.
|
1244
|
+
#
|
1245
|
+
# @!macro request_kwargs
|
1246
|
+
#
|
1247
|
+
# @yield [response]
|
1248
|
+
# If a block is given it will be passed the received HTTP response.
|
1249
|
+
#
|
1250
|
+
# @yieldparam [Net::HTTPResponse] response
|
1251
|
+
# The received HTTP response object.
|
1252
|
+
#
|
1253
|
+
# @return [Net::HTTPResponse]
|
1254
|
+
# The new HTTP Request object.
|
1255
|
+
#
|
1256
|
+
# @since 1.0.0
|
1257
|
+
#
|
1258
|
+
def propfind(path,**kwargs,&block)
|
1259
|
+
request(:propfind,path,**kwargs,&block)
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
alias prop_find propfind
|
1263
|
+
|
1264
|
+
#
|
1265
|
+
# Sends a `PROPPATCH` HTTP request.
|
1266
|
+
#
|
1267
|
+
# @param [String] path
|
1268
|
+
# The path to to make the request for.
|
1269
|
+
#
|
1270
|
+
# @!macro request_kwargs
|
1271
|
+
#
|
1272
|
+
# @yield [response]
|
1273
|
+
# If a block is given it will be passed the received HTTP response.
|
1274
|
+
#
|
1275
|
+
# @yieldparam [Net::HTTPResponse] response
|
1276
|
+
# The received HTTP response object.
|
1277
|
+
#
|
1278
|
+
# @return [Net::HTTPResponse]
|
1279
|
+
# The new HTTP Request object.
|
1280
|
+
#
|
1281
|
+
# @since 1.0.0
|
1282
|
+
#
|
1283
|
+
def proppatch(path,**kwargs,&block)
|
1284
|
+
request(:proppatch,path,**kwargs,&block)
|
1285
|
+
end
|
1286
|
+
|
1287
|
+
alias prop_patch proppatch
|
1288
|
+
|
1289
|
+
#
|
1290
|
+
# Sends a `PUT` HTTP request.
|
1291
|
+
#
|
1292
|
+
# @param [String] path
|
1293
|
+
# The path to to make the request for.
|
1294
|
+
#
|
1295
|
+
# @!macro request_kwargs
|
1296
|
+
#
|
1297
|
+
# @yield [response]
|
1298
|
+
# If a block is given it will be passed the received HTTP response.
|
1299
|
+
#
|
1300
|
+
# @yieldparam [Net::HTTPResponse] response
|
1301
|
+
# The received HTTP response object.
|
1302
|
+
#
|
1303
|
+
# @return [Net::HTTPResponse]
|
1304
|
+
# The new HTTP Request object.
|
1305
|
+
#
|
1306
|
+
# @since 1.0.0
|
1307
|
+
#
|
1308
|
+
def put(path,**kwargs,&block)
|
1309
|
+
request(:put,path,**kwargs,&block)
|
1310
|
+
end
|
1311
|
+
|
1312
|
+
#
|
1313
|
+
# Sends a `TRACE` HTTP request.
|
1314
|
+
#
|
1315
|
+
# @param [String] path
|
1316
|
+
# The path to to make the request for.
|
1317
|
+
#
|
1318
|
+
# @!macro request_kwargs
|
1319
|
+
#
|
1320
|
+
# @yield [response]
|
1321
|
+
# If a block is given it will be passed the received HTTP response.
|
1322
|
+
#
|
1323
|
+
# @yieldparam [Net::HTTPResponse] response
|
1324
|
+
# The received HTTP response object.
|
1325
|
+
#
|
1326
|
+
# @return [Net::HTTPResponse]
|
1327
|
+
# The new HTTP Request object.
|
1328
|
+
#
|
1329
|
+
# @since 1.0.0
|
1330
|
+
#
|
1331
|
+
def trace(path,**kwargs,&block)
|
1332
|
+
request(:trace,path,**kwargs,&block)
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
#
|
1336
|
+
# Sends a `UNLOCK` HTTP request.
|
1337
|
+
#
|
1338
|
+
# @param [String] path
|
1339
|
+
# The path to to make the request for.
|
1340
|
+
#
|
1341
|
+
# @!macro request_kwargs
|
1342
|
+
#
|
1343
|
+
# @yield [response]
|
1344
|
+
# If a block is given it will be passed the received HTTP response.
|
1345
|
+
#
|
1346
|
+
# @yieldparam [Net::HTTPResponse] response
|
1347
|
+
# The received HTTP response object.
|
1348
|
+
#
|
1349
|
+
# @return [Net::HTTPResponse]
|
1350
|
+
# The new HTTP Request object.
|
1351
|
+
#
|
1352
|
+
# @since 1.0.0
|
1353
|
+
#
|
1354
|
+
def unlock(path,**kwargs,&block)
|
1355
|
+
request(:unlock,path,**kwargs,&block)
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
#
|
1359
|
+
# Closes the HTTP connection.
|
1360
|
+
#
|
1361
|
+
# @since 1.0.0
|
1362
|
+
#
|
1363
|
+
def close
|
1364
|
+
@http.finish if @http.started?
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
#
|
1368
|
+
# Performs and arbitrary HTTP request.
|
1369
|
+
#
|
1370
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
1371
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
1372
|
+
# :trace, :unlock] method
|
1373
|
+
# The HTTP method to use for the request.
|
1374
|
+
#
|
1375
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1376
|
+
# Optional URL to create the HTTP request for.
|
1377
|
+
#
|
1378
|
+
# @!macro request_kwargs
|
1379
|
+
# @!macro initialize_kwargs
|
1380
|
+
#
|
1381
|
+
# @yield [response]
|
1382
|
+
# If a block is given it will be passed the received HTTP response.
|
1383
|
+
#
|
1384
|
+
# @yieldparam [Net::HTTPRresponse] response
|
1385
|
+
# The received HTTP response object.
|
1386
|
+
#
|
1387
|
+
# @return [Net::HTTPResponse]
|
1388
|
+
# The new HTTP Request object.
|
1389
|
+
#
|
1390
|
+
# @raise [ArgumentError]
|
1391
|
+
# The `:method` option did not match a known `Net::HTTP` request
|
1392
|
+
# class.
|
1393
|
+
#
|
1394
|
+
# @see .connect_uri
|
1395
|
+
# @see #request
|
1396
|
+
#
|
1397
|
+
def self.request(method,url, proxy: self.proxy,
|
1398
|
+
ssl: nil,
|
1399
|
+
headers: {},
|
1400
|
+
user_agent: nil,
|
1401
|
+
cookie: nil,
|
1402
|
+
user: nil,
|
1403
|
+
password: nil,
|
1404
|
+
**kwargs,
|
1405
|
+
&block)
|
1406
|
+
url = URI(url)
|
1407
|
+
path = url.request_uri
|
1408
|
+
http = connect_uri(url, proxy: proxy,
|
1409
|
+
ssl: ssl,
|
1410
|
+
headers: headers,
|
1411
|
+
user_agent: user_agent,
|
1412
|
+
cookie: cookie,
|
1413
|
+
user: user,
|
1414
|
+
password: password)
|
1415
|
+
|
1416
|
+
http.request(method,path,**kwargs,&block)
|
1417
|
+
end
|
1418
|
+
|
1419
|
+
#
|
1420
|
+
# Sends an arbitrary HTTP request and returns the response status.
|
1421
|
+
#
|
1422
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
1423
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
1424
|
+
# :trace, :unlock] method
|
1425
|
+
# The HTTP method to use for the request.
|
1426
|
+
#
|
1427
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1428
|
+
# Optional URL to create the HTTP request for.
|
1429
|
+
#
|
1430
|
+
# @!macro request_kwargs
|
1431
|
+
# @!macro initialize_kwargs
|
1432
|
+
#
|
1433
|
+
# @return [Integer]
|
1434
|
+
# The status code of the response.
|
1435
|
+
#
|
1436
|
+
# @see connect_uri
|
1437
|
+
# @see #response_status
|
1438
|
+
#
|
1439
|
+
# @since 1.0.0
|
1440
|
+
#
|
1441
|
+
def self.response_status(method=:head,url, proxy: self.proxy,
|
1442
|
+
ssl: nil,
|
1443
|
+
headers: {},
|
1444
|
+
user_agent: nil,
|
1445
|
+
cookie: nil,
|
1446
|
+
user: nil,
|
1447
|
+
password: nil,
|
1448
|
+
**kwargs)
|
1449
|
+
url = URI(url)
|
1450
|
+
path = url.request_uri
|
1451
|
+
http = connect_uri(url, proxy: proxy,
|
1452
|
+
ssl: ssl,
|
1453
|
+
headers: headers,
|
1454
|
+
user_agent: user_agent,
|
1455
|
+
cookie: cookie,
|
1456
|
+
user: user,
|
1457
|
+
password: password)
|
1458
|
+
|
1459
|
+
http.response_status(method,path,**kwargs)
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
#
|
1463
|
+
# Sends a HTTP request and determines if the response status was 200.
|
1464
|
+
#
|
1465
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
1466
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
1467
|
+
# :trace, :unlock] method
|
1468
|
+
# The HTTP method to use for the request.
|
1469
|
+
#
|
1470
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1471
|
+
# Optional URL to create the HTTP request for.
|
1472
|
+
#
|
1473
|
+
# @!macro request_kwargs
|
1474
|
+
# @!macro initialize_kwargs
|
1475
|
+
#
|
1476
|
+
# @return [Boolean]
|
1477
|
+
# Indicates that the response status was 200.
|
1478
|
+
#
|
1479
|
+
# @see connect_uri
|
1480
|
+
# @see #ok?
|
1481
|
+
#
|
1482
|
+
# @since 1.0.0
|
1483
|
+
#
|
1484
|
+
def self.ok?(method=:head,url, proxy: self.proxy,
|
1485
|
+
ssl: nil,
|
1486
|
+
headers: {},
|
1487
|
+
user_agent: nil,
|
1488
|
+
cookie: nil,
|
1489
|
+
user: nil,
|
1490
|
+
password: nil,
|
1491
|
+
**kwargs)
|
1492
|
+
url = URI(url)
|
1493
|
+
path = url.request_uri
|
1494
|
+
http = connect_uri(url, proxy: proxy,
|
1495
|
+
ssl: ssl,
|
1496
|
+
headers: headers,
|
1497
|
+
user_agent: user_agent,
|
1498
|
+
cookie: cookie,
|
1499
|
+
user: user,
|
1500
|
+
password: password)
|
1501
|
+
|
1502
|
+
http.ok?(method,path,**kwargs)
|
1503
|
+
end
|
1504
|
+
|
1505
|
+
#
|
1506
|
+
# Sends an arbitrary HTTP request and returns the response headers.
|
1507
|
+
#
|
1508
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
1509
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
1510
|
+
# :trace, :unlock] method
|
1511
|
+
# The HTTP method to use for the request.
|
1512
|
+
#
|
1513
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1514
|
+
# Optional URL to create the HTTP request for.
|
1515
|
+
#
|
1516
|
+
# @!macro request_kwargs
|
1517
|
+
# @!macro initialize_kwargs
|
1518
|
+
#
|
1519
|
+
# @return [Hash{String => String}]
|
1520
|
+
# The response headers.
|
1521
|
+
#
|
1522
|
+
# @see connect_uri
|
1523
|
+
# @see #response_headers
|
1524
|
+
#
|
1525
|
+
# @since 1.0.0
|
1526
|
+
#
|
1527
|
+
def self.response_headers(method=:head,url, proxy: self.proxy,
|
1528
|
+
ssl: nil,
|
1529
|
+
headers: {},
|
1530
|
+
user_agent: nil,
|
1531
|
+
cookie: nil,
|
1532
|
+
user: nil,
|
1533
|
+
password: nil,
|
1534
|
+
**kwargs)
|
1535
|
+
url = URI(url)
|
1536
|
+
path = url.request_uri
|
1537
|
+
http = connect_uri(url, proxy: proxy,
|
1538
|
+
ssl: ssl,
|
1539
|
+
headers: headers,
|
1540
|
+
user_agent: user_agent,
|
1541
|
+
cookie: cookie,
|
1542
|
+
user: user,
|
1543
|
+
password: password)
|
1544
|
+
|
1545
|
+
http.response_headers(method,path,**kwargs)
|
1546
|
+
end
|
1547
|
+
|
1548
|
+
#
|
1549
|
+
# Sends an HTTP request and returns the `Server` header.
|
1550
|
+
#
|
1551
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1552
|
+
# Optional URL to create the HTTP request for.
|
1553
|
+
#
|
1554
|
+
# @!macro request_kwargs
|
1555
|
+
# @!macro initialize_kwargs
|
1556
|
+
#
|
1557
|
+
# @return [String, nil]
|
1558
|
+
# The `Server` header.
|
1559
|
+
#
|
1560
|
+
# @see connect_uri
|
1561
|
+
# @see #server_header
|
1562
|
+
#
|
1563
|
+
# @since 1.0.0
|
1564
|
+
#
|
1565
|
+
def self.server_header(url, proxy: self.proxy,
|
1566
|
+
ssl: nil,
|
1567
|
+
headers: {},
|
1568
|
+
user_agent: nil,
|
1569
|
+
cookie: nil,
|
1570
|
+
user: nil,
|
1571
|
+
password: nil,
|
1572
|
+
**kwargs)
|
1573
|
+
url = URI(url)
|
1574
|
+
path = url.request_uri
|
1575
|
+
http = connect_uri(url, proxy: proxy,
|
1576
|
+
ssl: ssl,
|
1577
|
+
headers: headers,
|
1578
|
+
user_agent: user_agent,
|
1579
|
+
cookie: cookie,
|
1580
|
+
user: user,
|
1581
|
+
password: password)
|
1582
|
+
|
1583
|
+
http.server_header(path: path, **kwargs)
|
1584
|
+
end
|
1585
|
+
|
1586
|
+
#
|
1587
|
+
# Sends an HTTP request and returns the `X-Powered-By` header.
|
1588
|
+
#
|
1589
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1590
|
+
# Optional URL to create the HTTP request for.
|
1591
|
+
#
|
1592
|
+
# @!macro request_kwargs
|
1593
|
+
# @!macro initialize_kwargs
|
1594
|
+
#
|
1595
|
+
# @return [String, nil]
|
1596
|
+
# The `X-Powered-By` header.
|
1597
|
+
#
|
1598
|
+
# @see connect_uri
|
1599
|
+
# @see #powered_by_header
|
1600
|
+
#
|
1601
|
+
# @since 1.0.0
|
1602
|
+
#
|
1603
|
+
def self.powered_by_header(url, proxy: self.proxy,
|
1604
|
+
ssl: nil,
|
1605
|
+
headers: {},
|
1606
|
+
user_agent: nil,
|
1607
|
+
cookie: nil,
|
1608
|
+
user: nil,
|
1609
|
+
password: nil,
|
1610
|
+
**kwargs)
|
1611
|
+
url = URI(url)
|
1612
|
+
path = url.request_uri
|
1613
|
+
http = connect_uri(url, proxy: proxy,
|
1614
|
+
ssl: ssl,
|
1615
|
+
headers: headers,
|
1616
|
+
user_agent: user_agent,
|
1617
|
+
cookie: cookie,
|
1618
|
+
user: user,
|
1619
|
+
password: password)
|
1620
|
+
|
1621
|
+
http.powered_by_header(path: path, **kwargs)
|
1622
|
+
end
|
1623
|
+
|
1624
|
+
#
|
1625
|
+
# Sends an arbitrary HTTP request and returns the response body.
|
1626
|
+
#
|
1627
|
+
# @param [:copy, :delete, :get, :head, :lock, :mkcol, :move,
|
1628
|
+
# :options, :patch, :post, :propfind, :proppatch, :put,
|
1629
|
+
# :trace, :unlock] method
|
1630
|
+
# The HTTP method to use for the request.
|
1631
|
+
#
|
1632
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1633
|
+
# Optional URL to create the HTTP request for.
|
1634
|
+
#
|
1635
|
+
# @!macro request_kwargs
|
1636
|
+
# @!macro initialize_kwargs
|
1637
|
+
#
|
1638
|
+
# @return [String]
|
1639
|
+
# The response body.
|
1640
|
+
#
|
1641
|
+
# @see connect_uri
|
1642
|
+
# @see #response_body
|
1643
|
+
#
|
1644
|
+
# @since 1.0.0
|
1645
|
+
#
|
1646
|
+
def self.response_body(method=:get,url, proxy: self.proxy,
|
1647
|
+
ssl: nil,
|
1648
|
+
headers: {},
|
1649
|
+
user_agent: nil,
|
1650
|
+
cookie: nil,
|
1651
|
+
user: nil,
|
1652
|
+
password: nil,
|
1653
|
+
**kwargs)
|
1654
|
+
url = URI(url)
|
1655
|
+
path = url.request_uri
|
1656
|
+
http = connect_uri(url, proxy: proxy,
|
1657
|
+
ssl: ssl,
|
1658
|
+
headers: headers,
|
1659
|
+
user_agent: user_agent,
|
1660
|
+
cookie: cookie,
|
1661
|
+
user: user,
|
1662
|
+
password: password)
|
1663
|
+
|
1664
|
+
http.response_body(method,path,**kwargs)
|
1665
|
+
end
|
1666
|
+
|
1667
|
+
#
|
1668
|
+
# Performs a `COPY` request for the given URI.
|
1669
|
+
#
|
1670
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1671
|
+
# Optional URL to create the HTTP request for.
|
1672
|
+
#
|
1673
|
+
# @!macro request_kwargs
|
1674
|
+
# @!macro initialize_kwargs
|
1675
|
+
#
|
1676
|
+
# @yield [response]
|
1677
|
+
# If a block is given it will be passed the received HTTP response.
|
1678
|
+
#
|
1679
|
+
# @yieldparam [Net::HTTPRresponse] response
|
1680
|
+
# The received HTTP response object.
|
1681
|
+
#
|
1682
|
+
# @return [Net::HTTPResponse]
|
1683
|
+
# The new HTTP Request object.
|
1684
|
+
#
|
1685
|
+
# @see connect_uri
|
1686
|
+
# @see #copy
|
1687
|
+
#
|
1688
|
+
# @since 1.0.0
|
1689
|
+
#
|
1690
|
+
def self.copy(url, proxy: self.proxy,
|
1691
|
+
ssl: nil,
|
1692
|
+
headers: {},
|
1693
|
+
user_agent: nil,
|
1694
|
+
cookie: nil,
|
1695
|
+
user: nil,
|
1696
|
+
password: nil,
|
1697
|
+
**kwargs,
|
1698
|
+
&block)
|
1699
|
+
url = URI(url)
|
1700
|
+
path = url.request_uri
|
1701
|
+
http = connect_uri(url, proxy: proxy,
|
1702
|
+
ssl: ssl,
|
1703
|
+
headers: headers,
|
1704
|
+
user_agent: user_agent,
|
1705
|
+
cookie: cookie,
|
1706
|
+
user: user,
|
1707
|
+
password: password)
|
1708
|
+
|
1709
|
+
http.copy(path,**kwargs,&block)
|
1710
|
+
end
|
1711
|
+
|
1712
|
+
#
|
1713
|
+
# Performs a `DELETE` request for the given URI.
|
1714
|
+
#
|
1715
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1716
|
+
# Optional URL to create the HTTP request for.
|
1717
|
+
#
|
1718
|
+
# @!macro request_kwargs
|
1719
|
+
# @!macro initialize_kwargs
|
1720
|
+
#
|
1721
|
+
# @yield [response]
|
1722
|
+
# If a block is given it will be passed the received HTTP response.
|
1723
|
+
#
|
1724
|
+
# @yieldparam [Net::HTTPRresponse] response
|
1725
|
+
# The received HTTP response object.
|
1726
|
+
#
|
1727
|
+
# @return [Net::HTTPResponse]
|
1728
|
+
# The new HTTP Request object.
|
1729
|
+
#
|
1730
|
+
# @see connect_uri
|
1731
|
+
# @see #delete
|
1732
|
+
#
|
1733
|
+
# @since 1.0.0
|
1734
|
+
#
|
1735
|
+
def self.delete(url, proxy: self.proxy,
|
1736
|
+
ssl: nil,
|
1737
|
+
headers: {},
|
1738
|
+
user_agent: nil,
|
1739
|
+
cookie: nil,
|
1740
|
+
user: nil,
|
1741
|
+
password: nil,
|
1742
|
+
**kwargs,
|
1743
|
+
&block)
|
1744
|
+
url = URI(url)
|
1745
|
+
path = url.request_uri
|
1746
|
+
http = connect_uri(url, proxy: proxy,
|
1747
|
+
ssl: ssl,
|
1748
|
+
headers: headers,
|
1749
|
+
user_agent: user_agent,
|
1750
|
+
cookie: cookie,
|
1751
|
+
user: user,
|
1752
|
+
password: password)
|
1753
|
+
|
1754
|
+
http.delete(path,**kwargs,&block)
|
1755
|
+
end
|
1756
|
+
|
1757
|
+
#
|
1758
|
+
# Performs a `GET` request for the given URI.
|
1759
|
+
#
|
1760
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1761
|
+
# Optional URL to create the HTTP request for.
|
1762
|
+
#
|
1763
|
+
# @!macro request_kwargs
|
1764
|
+
# @!macro initialize_kwargs
|
1765
|
+
#
|
1766
|
+
# @yield [response]
|
1767
|
+
# If a block is given it will be passed the received HTTP response.
|
1768
|
+
#
|
1769
|
+
# @yieldparam [Net::HTTPRresponse] response
|
1770
|
+
# The received HTTP response object.
|
1771
|
+
#
|
1772
|
+
# @return [Net::HTTPResponse]
|
1773
|
+
# The new HTTP Request object.
|
1774
|
+
#
|
1775
|
+
# @see connect_uri
|
1776
|
+
# @see #get
|
1777
|
+
#
|
1778
|
+
# @since 1.0.0
|
1779
|
+
#
|
1780
|
+
def self.get(url, proxy: self.proxy,
|
1781
|
+
ssl: nil,
|
1782
|
+
headers: {},
|
1783
|
+
user_agent: nil,
|
1784
|
+
cookie: nil,
|
1785
|
+
user: nil,
|
1786
|
+
password: nil,
|
1787
|
+
**kwargs,
|
1788
|
+
&block)
|
1789
|
+
url = URI(url)
|
1790
|
+
path = url.request_uri
|
1791
|
+
http = connect_uri(url, proxy: proxy,
|
1792
|
+
ssl: ssl,
|
1793
|
+
headers: headers,
|
1794
|
+
user_agent: user_agent,
|
1795
|
+
cookie: cookie,
|
1796
|
+
user: user,
|
1797
|
+
password: password)
|
1798
|
+
|
1799
|
+
http.get(path,**kwargs,&block)
|
1800
|
+
end
|
1801
|
+
|
1802
|
+
#
|
1803
|
+
# Performs a `GET` request for the given URI and returns the response
|
1804
|
+
# headers.
|
1805
|
+
#
|
1806
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1807
|
+
# Optional URL to create the HTTP request for.
|
1808
|
+
#
|
1809
|
+
# @!macro request_kwargs
|
1810
|
+
# @!macro initialize_kwargs
|
1811
|
+
#
|
1812
|
+
# @return [Hash{String => String}]
|
1813
|
+
# The response headers.
|
1814
|
+
#
|
1815
|
+
# @see connect_uri
|
1816
|
+
# @see #get_headers
|
1817
|
+
#
|
1818
|
+
# @since 1.0.0
|
1819
|
+
#
|
1820
|
+
def self.get_headers(url, proxy: self.proxy,
|
1821
|
+
ssl: nil,
|
1822
|
+
headers: {},
|
1823
|
+
user_agent: nil,
|
1824
|
+
cookie: nil,
|
1825
|
+
user: nil,
|
1826
|
+
password: nil,
|
1827
|
+
**kwargs)
|
1828
|
+
url = URI(url)
|
1829
|
+
path = url.request_uri
|
1830
|
+
http = connect_uri(url, proxy: proxy,
|
1831
|
+
ssl: ssl,
|
1832
|
+
headers: headers,
|
1833
|
+
user_agent: user_agent,
|
1834
|
+
cookie: cookie,
|
1835
|
+
user: user,
|
1836
|
+
password: password)
|
1837
|
+
|
1838
|
+
http.get_headers(path,**kwargs)
|
1839
|
+
end
|
1840
|
+
|
1841
|
+
#
|
1842
|
+
# Sends an HTTP request and returns the parsed `Set-Cookie` header(s).
|
1843
|
+
#
|
1844
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1845
|
+
# Optional URL to create the HTTP request for.
|
1846
|
+
#
|
1847
|
+
# @!macro request_kwargs
|
1848
|
+
# @!macro initialize_kwargs
|
1849
|
+
#
|
1850
|
+
# @return [Array<SetCookie>, nil]
|
1851
|
+
# The parsed `SetCookie` header(s).
|
1852
|
+
#
|
1853
|
+
# @see connect_uri
|
1854
|
+
# @see #get_cookies
|
1855
|
+
#
|
1856
|
+
# @since 1.0.0
|
1857
|
+
#
|
1858
|
+
def self.get_cookies(url, proxy: self.proxy,
|
1859
|
+
ssl: nil,
|
1860
|
+
headers: {},
|
1861
|
+
user_agent: nil,
|
1862
|
+
cookie: nil,
|
1863
|
+
user: nil,
|
1864
|
+
password: nil,
|
1865
|
+
**kwargs)
|
1866
|
+
url = URI(url)
|
1867
|
+
path = url.request_uri
|
1868
|
+
http = connect_uri(url, proxy: proxy,
|
1869
|
+
ssl: ssl,
|
1870
|
+
headers: headers,
|
1871
|
+
user_agent: user_agent,
|
1872
|
+
cookie: cookie,
|
1873
|
+
user: user,
|
1874
|
+
password: password)
|
1875
|
+
|
1876
|
+
http.get_cookies(path, **kwargs)
|
1877
|
+
end
|
1878
|
+
|
1879
|
+
#
|
1880
|
+
# Performs a `GET` request for the given URI and returns the response
|
1881
|
+
# body.
|
1882
|
+
#
|
1883
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1884
|
+
# Optional URL to create the HTTP request for.
|
1885
|
+
#
|
1886
|
+
# @!macro request_kwargs
|
1887
|
+
# @!macro initialize_kwargs
|
1888
|
+
#
|
1889
|
+
# @return [String]
|
1890
|
+
# The response body.
|
1891
|
+
#
|
1892
|
+
# @see connect_uri
|
1893
|
+
# @see #get_body
|
1894
|
+
#
|
1895
|
+
# @since 1.0.0
|
1896
|
+
#
|
1897
|
+
def self.get_body(url, proxy: self.proxy,
|
1898
|
+
ssl: nil,
|
1899
|
+
headers: {},
|
1900
|
+
user_agent: nil,
|
1901
|
+
cookie: nil,
|
1902
|
+
user: nil,
|
1903
|
+
password: nil,
|
1904
|
+
**kwargs)
|
1905
|
+
url = URI(url)
|
1906
|
+
path = url.request_uri
|
1907
|
+
http = connect_uri(url, proxy: proxy,
|
1908
|
+
ssl: ssl,
|
1909
|
+
headers: headers,
|
1910
|
+
user_agent: user_agent,
|
1911
|
+
cookie: cookie,
|
1912
|
+
user: user,
|
1913
|
+
password: password)
|
1914
|
+
|
1915
|
+
http.get_body(path,**kwargs)
|
1916
|
+
end
|
1917
|
+
|
1918
|
+
#
|
1919
|
+
# Performs a `HEAD` request for the given URI.
|
1920
|
+
#
|
1921
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1922
|
+
# Optional URL to create the HTTP request for.
|
1923
|
+
#
|
1924
|
+
# @!macro request_kwargs
|
1925
|
+
# @!macro initialize_kwargs
|
1926
|
+
#
|
1927
|
+
# @yield [response]
|
1928
|
+
# If a block is given it will be passed the received HTTP response.
|
1929
|
+
#
|
1930
|
+
# @yieldparam [Net::HTTPRresponse] response
|
1931
|
+
# The received HTTP response object.
|
1932
|
+
#
|
1933
|
+
# @return [Net::HTTPResponse]
|
1934
|
+
# The new HTTP Request object.
|
1935
|
+
#
|
1936
|
+
# @see connect_uri
|
1937
|
+
# @see #head
|
1938
|
+
#
|
1939
|
+
# @since 1.0.0
|
1940
|
+
#
|
1941
|
+
def self.head(url, proxy: self.proxy,
|
1942
|
+
ssl: nil,
|
1943
|
+
headers: {},
|
1944
|
+
user_agent: nil,
|
1945
|
+
cookie: nil,
|
1946
|
+
user: nil,
|
1947
|
+
password: nil,
|
1948
|
+
**kwargs,
|
1949
|
+
&block)
|
1950
|
+
url = URI(url)
|
1951
|
+
path = url.request_uri
|
1952
|
+
http = connect_uri(url, proxy: proxy,
|
1953
|
+
ssl: ssl,
|
1954
|
+
headers: headers,
|
1955
|
+
user_agent: user_agent,
|
1956
|
+
cookie: cookie,
|
1957
|
+
user: user,
|
1958
|
+
password: password)
|
1959
|
+
|
1960
|
+
http.head(path,**kwargs,&block)
|
1961
|
+
end
|
1962
|
+
|
1963
|
+
#
|
1964
|
+
# Performs a `LOCK` request for the given URI.
|
1965
|
+
#
|
1966
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
1967
|
+
# Optional URL to create the HTTP request for.
|
1968
|
+
#
|
1969
|
+
# @!macro request_kwargs
|
1970
|
+
# @!macro initialize_kwargs
|
1971
|
+
#
|
1972
|
+
# @yield [response]
|
1973
|
+
# If a block is given it will be passed the received HTTP response.
|
1974
|
+
#
|
1975
|
+
# @yieldparam [Net::HTTPRresponse] response
|
1976
|
+
# The received HTTP response object.
|
1977
|
+
#
|
1978
|
+
# @return [Net::HTTPResponse]
|
1979
|
+
# The new HTTP Request object.
|
1980
|
+
#
|
1981
|
+
# @see connect_uri
|
1982
|
+
# @see #lock
|
1983
|
+
#
|
1984
|
+
# @since 1.0.0
|
1985
|
+
#
|
1986
|
+
def self.lock(url, proxy: self.proxy,
|
1987
|
+
ssl: nil,
|
1988
|
+
headers: {},
|
1989
|
+
user_agent: nil,
|
1990
|
+
cookie: nil,
|
1991
|
+
user: nil,
|
1992
|
+
password: nil,
|
1993
|
+
**kwargs,
|
1994
|
+
&block)
|
1995
|
+
url = URI(url)
|
1996
|
+
path = url.request_uri
|
1997
|
+
http = connect_uri(url, proxy: proxy,
|
1998
|
+
ssl: ssl,
|
1999
|
+
headers: headers,
|
2000
|
+
user_agent: user_agent,
|
2001
|
+
cookie: cookie,
|
2002
|
+
user: user,
|
2003
|
+
password: password)
|
2004
|
+
|
2005
|
+
http.lock(path,**kwargs,&block)
|
2006
|
+
end
|
2007
|
+
|
2008
|
+
#
|
2009
|
+
# Performs a `MKCOL` request for the given URI.
|
2010
|
+
#
|
2011
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2012
|
+
# Optional URL to create the HTTP request for.
|
2013
|
+
#
|
2014
|
+
# @!macro request_kwargs
|
2015
|
+
# @!macro initialize_kwargs
|
2016
|
+
#
|
2017
|
+
# @yield [response]
|
2018
|
+
# If a block is given it will be passed the received HTTP response.
|
2019
|
+
#
|
2020
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2021
|
+
# The received HTTP response object.
|
2022
|
+
#
|
2023
|
+
# @return [Net::HTTPResponse]
|
2024
|
+
# The new HTTP Request object.
|
2025
|
+
#
|
2026
|
+
# @see connect_uri
|
2027
|
+
# @see #mkcol
|
2028
|
+
#
|
2029
|
+
# @since 1.0.0
|
2030
|
+
#
|
2031
|
+
def self.mkcol(url, proxy: self.proxy,
|
2032
|
+
ssl: nil,
|
2033
|
+
headers: {},
|
2034
|
+
user_agent: nil,
|
2035
|
+
cookie: nil,
|
2036
|
+
user: nil,
|
2037
|
+
password: nil,
|
2038
|
+
**kwargs,
|
2039
|
+
&block)
|
2040
|
+
url = URI(url)
|
2041
|
+
path = url.request_uri
|
2042
|
+
http = connect_uri(url, proxy: proxy,
|
2043
|
+
ssl: ssl,
|
2044
|
+
headers: headers,
|
2045
|
+
user_agent: user_agent,
|
2046
|
+
cookie: cookie,
|
2047
|
+
user: user,
|
2048
|
+
password: password)
|
2049
|
+
|
2050
|
+
http.mkcol(path,**kwargs,&block)
|
2051
|
+
end
|
2052
|
+
|
2053
|
+
#
|
2054
|
+
# Performs a `MOVE` request for the given URI.
|
2055
|
+
#
|
2056
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2057
|
+
# Optional URL to create the HTTP request for.
|
2058
|
+
#
|
2059
|
+
# @!macro request_kwargs
|
2060
|
+
# @!macro initialize_kwargs
|
2061
|
+
#
|
2062
|
+
# @yield [response]
|
2063
|
+
# If a block is given it will be passed the received HTTP response.
|
2064
|
+
#
|
2065
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2066
|
+
# The received HTTP response object.
|
2067
|
+
#
|
2068
|
+
# @return [Net::HTTPResponse]
|
2069
|
+
# The new HTTP Request object.
|
2070
|
+
#
|
2071
|
+
# @see connect_uri
|
2072
|
+
# @see #move
|
2073
|
+
#
|
2074
|
+
# @since 1.0.0
|
2075
|
+
#
|
2076
|
+
def self.move(url, proxy: self.proxy,
|
2077
|
+
ssl: nil,
|
2078
|
+
headers: {},
|
2079
|
+
user_agent: nil,
|
2080
|
+
cookie: nil,
|
2081
|
+
user: nil,
|
2082
|
+
password: nil,
|
2083
|
+
**kwargs,
|
2084
|
+
&block)
|
2085
|
+
url = URI(url)
|
2086
|
+
path = url.request_uri
|
2087
|
+
http = connect_uri(url, proxy: proxy,
|
2088
|
+
ssl: ssl,
|
2089
|
+
headers: headers,
|
2090
|
+
user_agent: user_agent,
|
2091
|
+
cookie: cookie,
|
2092
|
+
user: user,
|
2093
|
+
password: password)
|
2094
|
+
|
2095
|
+
http.move(path,**kwargs,&block)
|
2096
|
+
end
|
2097
|
+
|
2098
|
+
#
|
2099
|
+
# Performs a `OPTIONS` request for the given URI.
|
2100
|
+
#
|
2101
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2102
|
+
# Optional URL to create the HTTP request for.
|
2103
|
+
#
|
2104
|
+
# @!macro request_kwargs
|
2105
|
+
# @!macro initialize_kwargs
|
2106
|
+
#
|
2107
|
+
# @yield [response]
|
2108
|
+
# If a block is given it will be passed the received HTTP response.
|
2109
|
+
#
|
2110
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2111
|
+
# The received HTTP response object.
|
2112
|
+
#
|
2113
|
+
# @return [Net::HTTPResponse]
|
2114
|
+
# The new HTTP Request object.
|
2115
|
+
#
|
2116
|
+
# @see connect_uri
|
2117
|
+
# @see #options
|
2118
|
+
#
|
2119
|
+
# @since 1.0.0
|
2120
|
+
#
|
2121
|
+
def self.options(url, proxy: self.proxy,
|
2122
|
+
ssl: nil,
|
2123
|
+
headers: {},
|
2124
|
+
user_agent: nil,
|
2125
|
+
cookie: nil,
|
2126
|
+
user: nil,
|
2127
|
+
password: nil,
|
2128
|
+
**kwargs,
|
2129
|
+
&block)
|
2130
|
+
url = URI(url)
|
2131
|
+
path = url.request_uri
|
2132
|
+
http = connect_uri(url, proxy: proxy,
|
2133
|
+
ssl: ssl,
|
2134
|
+
headers: headers,
|
2135
|
+
user_agent: user_agent,
|
2136
|
+
cookie: cookie,
|
2137
|
+
user: user,
|
2138
|
+
password: password)
|
2139
|
+
|
2140
|
+
http.options(path,**kwargs,&block)
|
2141
|
+
end
|
2142
|
+
|
2143
|
+
#
|
2144
|
+
# Performs a `OPTIONS` HTTP request for the given URI and parses the
|
2145
|
+
# `Allow` response header.
|
2146
|
+
#
|
2147
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2148
|
+
# Optional URL to create the HTTP request for.
|
2149
|
+
#
|
2150
|
+
# @!macro request_kwargs
|
2151
|
+
# @!macro initialize_kwargs
|
2152
|
+
#
|
2153
|
+
# @return [Array<Symbol>]
|
2154
|
+
# The allowed HTTP request methods for the given URL.
|
2155
|
+
#
|
2156
|
+
# @see connect_uri
|
2157
|
+
# @see #allowed_methods
|
2158
|
+
#
|
2159
|
+
# @since 1.0.0
|
2160
|
+
#
|
2161
|
+
def self.allowed_methods(url, proxy: self.proxy,
|
2162
|
+
ssl: nil,
|
2163
|
+
headers: {},
|
2164
|
+
user_agent: nil,
|
2165
|
+
cookie: nil,
|
2166
|
+
user: nil,
|
2167
|
+
password: nil,
|
2168
|
+
**kwargs)
|
2169
|
+
url = URI(url)
|
2170
|
+
path = url.request_uri
|
2171
|
+
http = connect_uri(url, proxy: proxy,
|
2172
|
+
ssl: ssl,
|
2173
|
+
headers: headers,
|
2174
|
+
user_agent: user_agent,
|
2175
|
+
cookie: cookie,
|
2176
|
+
user: user,
|
2177
|
+
password: password)
|
2178
|
+
|
2179
|
+
http.allowed_methods(path,**kwargs)
|
2180
|
+
end
|
2181
|
+
|
2182
|
+
|
2183
|
+
#
|
2184
|
+
# Performs a `PATCH` request for the given URI.
|
2185
|
+
#
|
2186
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2187
|
+
# Optional URL to create the HTTP request for.
|
2188
|
+
#
|
2189
|
+
# @!macro request_kwargs
|
2190
|
+
# @!macro initialize_kwargs
|
2191
|
+
#
|
2192
|
+
# @yield [response]
|
2193
|
+
# If a block is given it will be passed the received HTTP response.
|
2194
|
+
#
|
2195
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2196
|
+
# The received HTTP response object.
|
2197
|
+
#
|
2198
|
+
# @return [Net::HTTPResponse]
|
2199
|
+
# The new HTTP Request object.
|
2200
|
+
#
|
2201
|
+
# @see connect_uri
|
2202
|
+
# @see #patch
|
2203
|
+
#
|
2204
|
+
# @since 1.0.0
|
2205
|
+
#
|
2206
|
+
def self.patch(url, proxy: self.proxy,
|
2207
|
+
ssl: nil,
|
2208
|
+
headers: {},
|
2209
|
+
user_agent: nil,
|
2210
|
+
cookie: nil,
|
2211
|
+
user: nil,
|
2212
|
+
password: nil,
|
2213
|
+
**kwargs,
|
2214
|
+
&block)
|
2215
|
+
url = URI(url)
|
2216
|
+
path = url.request_uri
|
2217
|
+
http = connect_uri(url, proxy: proxy,
|
2218
|
+
ssl: ssl,
|
2219
|
+
headers: headers,
|
2220
|
+
user_agent: user_agent,
|
2221
|
+
cookie: cookie,
|
2222
|
+
user: user,
|
2223
|
+
password: password)
|
2224
|
+
|
2225
|
+
http.patch(path,**kwargs,&block)
|
2226
|
+
end
|
2227
|
+
|
2228
|
+
#
|
2229
|
+
# Performs a `POST` request for the given URI.
|
2230
|
+
#
|
2231
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2232
|
+
# Optional URL to create the HTTP request for.
|
2233
|
+
#
|
2234
|
+
# @!macro request_kwargs
|
2235
|
+
# @!macro initialize_kwargs
|
2236
|
+
#
|
2237
|
+
# @yield [response]
|
2238
|
+
# If a block is given it will be passed the received HTTP response.
|
2239
|
+
#
|
2240
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2241
|
+
# The received HTTP response object.
|
2242
|
+
#
|
2243
|
+
# @return [Net::HTTPResponse]
|
2244
|
+
# The new HTTP Request object.
|
2245
|
+
#
|
2246
|
+
# @see connect_uri
|
2247
|
+
# @see #post
|
2248
|
+
#
|
2249
|
+
# @since 1.0.0
|
2250
|
+
#
|
2251
|
+
def self.post(url, proxy: self.proxy,
|
2252
|
+
ssl: nil,
|
2253
|
+
headers: {},
|
2254
|
+
user_agent: nil,
|
2255
|
+
cookie: nil,
|
2256
|
+
user: nil,
|
2257
|
+
password: nil,
|
2258
|
+
**kwargs,
|
2259
|
+
&block)
|
2260
|
+
url = URI(url)
|
2261
|
+
path = url.request_uri
|
2262
|
+
http = connect_uri(url, proxy: proxy,
|
2263
|
+
ssl: ssl,
|
2264
|
+
headers: headers,
|
2265
|
+
user_agent: user_agent,
|
2266
|
+
cookie: cookie,
|
2267
|
+
user: user,
|
2268
|
+
password: password)
|
2269
|
+
|
2270
|
+
http.post(path,**kwargs,&block)
|
2271
|
+
end
|
2272
|
+
|
2273
|
+
#
|
2274
|
+
# Performs a `POST` request on the given URI and returns the response
|
2275
|
+
# headers.
|
2276
|
+
#
|
2277
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2278
|
+
# Optional URL to create the HTTP request for.
|
2279
|
+
#
|
2280
|
+
# @!macro request_kwargs
|
2281
|
+
# @!macro initialize_kwargs
|
2282
|
+
#
|
2283
|
+
# @return [Hash{String => String}]
|
2284
|
+
# The response headers.
|
2285
|
+
#
|
2286
|
+
# @see connect_uri
|
2287
|
+
# @see #post_headers
|
2288
|
+
#
|
2289
|
+
# @since 1.0.0
|
2290
|
+
#
|
2291
|
+
def self.post_headers(url, proxy: self.proxy,
|
2292
|
+
ssl: nil,
|
2293
|
+
headers: {},
|
2294
|
+
user_agent: nil,
|
2295
|
+
cookie: nil,
|
2296
|
+
user: nil,
|
2297
|
+
password: nil,
|
2298
|
+
**kwargs)
|
2299
|
+
url = URI(url)
|
2300
|
+
path = url.request_uri
|
2301
|
+
http = connect_uri(url, proxy: proxy,
|
2302
|
+
ssl: ssl,
|
2303
|
+
headers: headers,
|
2304
|
+
user_agent: user_agent,
|
2305
|
+
cookie: cookie,
|
2306
|
+
user: user,
|
2307
|
+
password: password)
|
2308
|
+
|
2309
|
+
http.post_headers(path,**kwargs)
|
2310
|
+
end
|
2311
|
+
|
2312
|
+
#
|
2313
|
+
# Performs a `POST` request for the given URI and returns the response
|
2314
|
+
# body.
|
2315
|
+
#
|
2316
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2317
|
+
# Optional URL to create the HTTP request for.
|
2318
|
+
#
|
2319
|
+
# @!macro request_kwargs
|
2320
|
+
# @!macro initialize_kwargs
|
2321
|
+
#
|
2322
|
+
# @return [String]
|
2323
|
+
# The response body.
|
2324
|
+
#
|
2325
|
+
# @see connect_uri
|
2326
|
+
# @see #post_body
|
2327
|
+
#
|
2328
|
+
# @since 1.0.0
|
2329
|
+
#
|
2330
|
+
def self.post_body(url, proxy: self.proxy,
|
2331
|
+
ssl: nil,
|
2332
|
+
headers: {},
|
2333
|
+
user_agent: nil,
|
2334
|
+
cookie: nil,
|
2335
|
+
user: nil,
|
2336
|
+
password: nil,
|
2337
|
+
**kwargs)
|
2338
|
+
url = URI(url)
|
2339
|
+
path = url.request_uri
|
2340
|
+
http = connect_uri(url, proxy: proxy,
|
2341
|
+
ssl: ssl,
|
2342
|
+
headers: headers,
|
2343
|
+
user_agent: user_agent,
|
2344
|
+
cookie: cookie,
|
2345
|
+
user: user,
|
2346
|
+
password: password)
|
2347
|
+
|
2348
|
+
http.post_body(path,**kwargs)
|
2349
|
+
end
|
2350
|
+
|
2351
|
+
#
|
2352
|
+
# Performs a `PROPFIND` request for the given URI.
|
2353
|
+
#
|
2354
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2355
|
+
# Optional URL to create the HTTP request for.
|
2356
|
+
#
|
2357
|
+
# @!macro request_kwargs
|
2358
|
+
# @!macro initialize_kwargs
|
2359
|
+
#
|
2360
|
+
# @yield [response]
|
2361
|
+
# If a block is given it will be passed the received HTTP response.
|
2362
|
+
#
|
2363
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2364
|
+
# The received HTTP response object.
|
2365
|
+
#
|
2366
|
+
# @return [Net::HTTPResponse]
|
2367
|
+
# The new HTTP Request object.
|
2368
|
+
#
|
2369
|
+
# @see connect_uri
|
2370
|
+
# @see #propfind
|
2371
|
+
#
|
2372
|
+
# @since 1.0.0
|
2373
|
+
#
|
2374
|
+
def self.propfind(url, proxy: self.proxy,
|
2375
|
+
ssl: nil,
|
2376
|
+
headers: {},
|
2377
|
+
user_agent: nil,
|
2378
|
+
cookie: nil,
|
2379
|
+
user: nil,
|
2380
|
+
password: nil,
|
2381
|
+
**kwargs,
|
2382
|
+
&block)
|
2383
|
+
url = URI(url)
|
2384
|
+
path = url.request_uri
|
2385
|
+
http = connect_uri(url, proxy: proxy,
|
2386
|
+
ssl: ssl,
|
2387
|
+
headers: headers,
|
2388
|
+
user_agent: user_agent,
|
2389
|
+
cookie: cookie,
|
2390
|
+
user: user,
|
2391
|
+
password: password)
|
2392
|
+
|
2393
|
+
http.propfind(path,**kwargs,&block)
|
2394
|
+
end
|
2395
|
+
|
2396
|
+
alias prop_find propfind
|
2397
|
+
|
2398
|
+
#
|
2399
|
+
# Performs a `PROPPATCH` request for the given URI.
|
2400
|
+
#
|
2401
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2402
|
+
# Optional URL to create the HTTP request for.
|
2403
|
+
#
|
2404
|
+
# @!macro request_kwargs
|
2405
|
+
# @!macro initialize_kwargs
|
2406
|
+
#
|
2407
|
+
# @yield [response]
|
2408
|
+
# If a block is given it will be passed the received HTTP response.
|
2409
|
+
#
|
2410
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2411
|
+
# The received HTTP response object.
|
2412
|
+
#
|
2413
|
+
# @return [Net::HTTPResponse]
|
2414
|
+
# The new HTTP Request object.
|
2415
|
+
#
|
2416
|
+
# @see connect_uri
|
2417
|
+
# @see #proppatch
|
2418
|
+
#
|
2419
|
+
# @since 1.0.0
|
2420
|
+
#
|
2421
|
+
def self.proppatch(url, proxy: self.proxy,
|
2422
|
+
ssl: nil,
|
2423
|
+
headers: {},
|
2424
|
+
user_agent: nil,
|
2425
|
+
cookie: nil,
|
2426
|
+
user: nil,
|
2427
|
+
password: nil,
|
2428
|
+
**kwargs,
|
2429
|
+
&block)
|
2430
|
+
url = URI(url)
|
2431
|
+
path = url.request_uri
|
2432
|
+
http = connect_uri(url, proxy: proxy,
|
2433
|
+
ssl: ssl,
|
2434
|
+
headers: headers,
|
2435
|
+
user_agent: user_agent,
|
2436
|
+
cookie: cookie,
|
2437
|
+
user: user,
|
2438
|
+
password: password)
|
2439
|
+
|
2440
|
+
http.proppatch(path,**kwargs,&block)
|
2441
|
+
end
|
2442
|
+
|
2443
|
+
alias prop_patch proppatch
|
2444
|
+
|
2445
|
+
#
|
2446
|
+
# Performs a `PUT` request for the given URI.
|
2447
|
+
#
|
2448
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2449
|
+
# Optional URL to create the HTTP request for.
|
2450
|
+
#
|
2451
|
+
# @!macro request_kwargs
|
2452
|
+
# @!macro initialize_kwargs
|
2453
|
+
#
|
2454
|
+
# @yield [response]
|
2455
|
+
# If a block is given it will be passed the received HTTP response.
|
2456
|
+
#
|
2457
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2458
|
+
# The received HTTP response object.
|
2459
|
+
#
|
2460
|
+
# @return [Net::HTTPResponse]
|
2461
|
+
# The new HTTP Request object.
|
2462
|
+
#
|
2463
|
+
# @see connect_uri
|
2464
|
+
# @see #put
|
2465
|
+
#
|
2466
|
+
# @since 1.0.0
|
2467
|
+
#
|
2468
|
+
def self.put(url, proxy: self.proxy,
|
2469
|
+
ssl: nil,
|
2470
|
+
headers: {},
|
2471
|
+
user_agent: nil,
|
2472
|
+
cookie: nil,
|
2473
|
+
user: nil,
|
2474
|
+
password: nil,
|
2475
|
+
**kwargs,
|
2476
|
+
&block)
|
2477
|
+
url = URI(url)
|
2478
|
+
path = url.request_uri
|
2479
|
+
http = connect_uri(url, proxy: proxy,
|
2480
|
+
ssl: ssl,
|
2481
|
+
headers: headers,
|
2482
|
+
user_agent: user_agent,
|
2483
|
+
cookie: cookie,
|
2484
|
+
user: user,
|
2485
|
+
password: password)
|
2486
|
+
|
2487
|
+
http.put(path,**kwargs,&block)
|
2488
|
+
end
|
2489
|
+
|
2490
|
+
#
|
2491
|
+
# Performs a `TRACE` request for the given URI.
|
2492
|
+
#
|
2493
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2494
|
+
# Optional URL to create the HTTP request for.
|
2495
|
+
#
|
2496
|
+
# @!macro request_kwargs
|
2497
|
+
# @!macro initialize_kwargs
|
2498
|
+
#
|
2499
|
+
# @yield [response]
|
2500
|
+
# If a block is given it will be passed the received HTTP response.
|
2501
|
+
#
|
2502
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2503
|
+
# The received HTTP response object.
|
2504
|
+
#
|
2505
|
+
# @return [Net::HTTPResponse]
|
2506
|
+
# The new HTTP Request object.
|
2507
|
+
#
|
2508
|
+
# @see connect_uri
|
2509
|
+
# @see #trace
|
2510
|
+
#
|
2511
|
+
# @since 1.0.0
|
2512
|
+
#
|
2513
|
+
def self.trace(url, proxy: self.proxy,
|
2514
|
+
ssl: nil,
|
2515
|
+
headers: {},
|
2516
|
+
user_agent: nil,
|
2517
|
+
cookie: nil,
|
2518
|
+
user: nil,
|
2519
|
+
password: nil,
|
2520
|
+
**kwargs,
|
2521
|
+
&block)
|
2522
|
+
url = URI(url)
|
2523
|
+
path = url.request_uri
|
2524
|
+
http = connect_uri(url, proxy: proxy,
|
2525
|
+
ssl: ssl,
|
2526
|
+
headers: headers,
|
2527
|
+
user_agent: user_agent,
|
2528
|
+
cookie: cookie,
|
2529
|
+
user: user,
|
2530
|
+
password: password)
|
2531
|
+
|
2532
|
+
http.trace(path,**kwargs,&block)
|
2533
|
+
end
|
2534
|
+
|
2535
|
+
#
|
2536
|
+
# Performs a `UNLOCK` request for the given URI.
|
2537
|
+
#
|
2538
|
+
# @param [URI::HTTP, Addressable::URI, String] url
|
2539
|
+
# Optional URL to create the HTTP request for.
|
2540
|
+
#
|
2541
|
+
# @!macro request_kwargs
|
2542
|
+
# @!macro initialize_kwargs
|
2543
|
+
#
|
2544
|
+
# @yield [response]
|
2545
|
+
# If a block is given it will be passed the received HTTP response.
|
2546
|
+
#
|
2547
|
+
# @yieldparam [Net::HTTPRresponse] response
|
2548
|
+
# The received HTTP response object.
|
2549
|
+
#
|
2550
|
+
# @return [Net::HTTPResponse]
|
2551
|
+
# The new HTTP Request object.
|
2552
|
+
#
|
2553
|
+
# @see connect_uri
|
2554
|
+
# @see #unlock
|
2555
|
+
#
|
2556
|
+
# @since 1.0.0
|
2557
|
+
#
|
2558
|
+
def self.unlock(url, proxy: self.proxy,
|
2559
|
+
ssl: nil,
|
2560
|
+
headers: {},
|
2561
|
+
user_agent: nil,
|
2562
|
+
cookie: nil,
|
2563
|
+
user: nil,
|
2564
|
+
password: nil,
|
2565
|
+
**kwargs,
|
2566
|
+
&block)
|
2567
|
+
url = URI(url)
|
2568
|
+
path = url.request_uri
|
2569
|
+
http = connect_uri(url, proxy: proxy,
|
2570
|
+
ssl: ssl,
|
2571
|
+
headers: headers,
|
2572
|
+
user_agent: user_agent,
|
2573
|
+
cookie: cookie,
|
2574
|
+
user: user,
|
2575
|
+
password: password)
|
2576
|
+
|
2577
|
+
http.unlock(path,**kwargs,&block)
|
2578
|
+
end
|
2579
|
+
end
|
2580
|
+
end
|
2581
|
+
end
|
2582
|
+
end
|