ronin-support 0.3.0 → 0.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +77 -7
- data/README.md +19 -3
- data/gemspec.yml +2 -2
- data/lib/ronin/extensions/regexp.rb +50 -2
- data/lib/ronin/extensions/string.rb +1 -0
- data/lib/ronin/formatting.rb +1 -0
- data/lib/ronin/formatting/extensions.rb +1 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +56 -5
- data/lib/ronin/formatting/extensions/html/string.rb +6 -7
- data/lib/ronin/formatting/extensions/sql/string.rb +34 -0
- data/lib/ronin/formatting/extensions/text/string.rb +0 -180
- data/lib/ronin/fuzzing.rb +21 -0
- data/lib/ronin/fuzzing/extensions.rb +20 -0
- data/lib/ronin/fuzzing/extensions/string.rb +380 -0
- data/lib/ronin/fuzzing/fuzzing.rb +191 -0
- data/lib/ronin/network/esmtp.rb +94 -1
- data/lib/ronin/network/extensions/esmtp/net.rb +2 -82
- data/lib/ronin/network/extensions/http/net.rb +1 -736
- data/lib/ronin/network/extensions/imap/net.rb +1 -103
- data/lib/ronin/network/extensions/pop3/net.rb +1 -71
- data/lib/ronin/network/extensions/smtp/net.rb +2 -157
- data/lib/ronin/network/extensions/ssl/net.rb +1 -132
- data/lib/ronin/network/extensions/tcp/net.rb +2 -296
- data/lib/ronin/network/extensions/telnet/net.rb +1 -135
- data/lib/ronin/network/extensions/udp/net.rb +2 -214
- data/lib/ronin/network/http/http.rb +750 -5
- data/lib/ronin/network/imap.rb +105 -2
- data/lib/ronin/network/mixins.rb +1 -1
- data/lib/ronin/network/mixins/esmtp.rb +49 -52
- data/lib/ronin/network/mixins/http.rb +49 -53
- data/lib/ronin/network/mixins/imap.rb +47 -44
- data/lib/ronin/network/mixins/mixin.rb +58 -0
- data/lib/ronin/network/mixins/pop3.rb +44 -38
- data/lib/ronin/network/mixins/smtp.rb +49 -51
- data/lib/ronin/network/mixins/tcp.rb +56 -69
- data/lib/ronin/network/mixins/telnet.rb +57 -50
- data/lib/ronin/network/mixins/udp.rb +48 -52
- data/lib/ronin/network/network.rb +1 -0
- data/lib/ronin/network/pop3.rb +72 -2
- data/lib/ronin/network/smtp/email.rb +1 -0
- data/lib/ronin/network/smtp/smtp.rb +159 -3
- data/lib/ronin/network/ssl.rb +131 -2
- data/lib/ronin/network/tcp.rb +306 -1
- data/lib/ronin/network/telnet.rb +136 -2
- data/lib/ronin/network/udp.rb +229 -1
- data/lib/ronin/support.rb +2 -3
- data/lib/ronin/support/support.rb +38 -0
- data/lib/ronin/support/version.rb +1 -1
- data/lib/ronin/templates/erb.rb +2 -1
- data/lib/ronin/ui/output/helpers.rb +35 -1
- data/lib/ronin/ui/shell.rb +12 -2
- data/lib/ronin/wordlist.rb +157 -0
- data/spec/extensions/regexp_spec.rb +38 -0
- data/spec/formatting/html/string_spec.rb +1 -1
- data/spec/formatting/sql/string_spec.rb +23 -3
- data/spec/formatting/text/string_spec.rb +0 -110
- data/spec/fuzzing/string_spec.rb +158 -0
- data/spec/wordlist_spec.rb +65 -0
- metadata +35 -27
@@ -19,21 +19,32 @@
|
|
19
19
|
|
20
20
|
require 'ronin/network/http/exceptions/unknown_request'
|
21
21
|
require 'ronin/network/http/proxy'
|
22
|
-
require 'ronin/network/
|
22
|
+
require 'ronin/network/ssl'
|
23
|
+
|
24
|
+
require 'uri/query_params'
|
25
|
+
require 'net/http'
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'net/https'
|
29
|
+
rescue ::LoadError
|
30
|
+
end
|
23
31
|
|
24
32
|
module Ronin
|
25
33
|
module Network
|
26
34
|
#
|
27
|
-
#
|
35
|
+
# Provides helper methods for communicating with HTTP Servers.
|
28
36
|
#
|
29
37
|
module HTTP
|
30
38
|
#
|
31
|
-
# The Ronin HTTP proxy to use.
|
32
|
-
# environment variable if set.
|
39
|
+
# The Ronin HTTP proxy to use.
|
33
40
|
#
|
34
41
|
# @return [Proxy]
|
35
42
|
# The Ronin HTTP proxy.
|
36
43
|
#
|
44
|
+
# @note
|
45
|
+
# If the `HTTP_PROXY` environment variable is specified, it will
|
46
|
+
# be used as the default value.
|
47
|
+
#
|
37
48
|
# @see Proxy.new
|
38
49
|
# @see Proxy.parse
|
39
50
|
#
|
@@ -155,7 +166,7 @@ module Ronin
|
|
155
166
|
# @option options [String] :path ('/')
|
156
167
|
# The path to request.
|
157
168
|
#
|
158
|
-
# @option options [String, Hash] :proxy (
|
169
|
+
# @option options [String, Hash] :proxy (HTTP.proxy)
|
159
170
|
# The Proxy information.
|
160
171
|
#
|
161
172
|
# @return [Hash]
|
@@ -310,6 +321,740 @@ module Ronin
|
|
310
321
|
|
311
322
|
return request
|
312
323
|
end
|
324
|
+
|
325
|
+
#
|
326
|
+
# Starts a HTTP connection with the server.
|
327
|
+
#
|
328
|
+
# @param [Hash] options
|
329
|
+
# Additional options
|
330
|
+
#
|
331
|
+
# @option options [String, URI::HTTP] :url
|
332
|
+
# The full URL to request.
|
333
|
+
#
|
334
|
+
# @option options [String] :host
|
335
|
+
# The host the HTTP server is running on.
|
336
|
+
#
|
337
|
+
# @option options [Integer] :port (Net::HTTP.default_port)
|
338
|
+
# The port the HTTP server is listening on.
|
339
|
+
#
|
340
|
+
# @option options [String, Hash] :proxy (HTTP.proxy)
|
341
|
+
# A Hash of proxy settings to use when connecting to the HTTP server.
|
342
|
+
#
|
343
|
+
# @option options [String] :user
|
344
|
+
# The user to authenticate with when connecting to the HTTP server.
|
345
|
+
#
|
346
|
+
# @option options [String] :password
|
347
|
+
# The password to authenticate with when connecting to the HTTP server.
|
348
|
+
#
|
349
|
+
# @option options [Boolean, Hash] :ssl
|
350
|
+
# Enables SSL for the HTTP connection.
|
351
|
+
#
|
352
|
+
# @option :ssl [Symbol] :verify
|
353
|
+
# Specifies the SSL certificate verification mode.
|
354
|
+
#
|
355
|
+
# @yield [session]
|
356
|
+
# If a block is given, it will be passed the newly created HTTP
|
357
|
+
# session object.
|
358
|
+
#
|
359
|
+
# @yieldparam [Net::HTTP] session
|
360
|
+
# The newly created HTTP session.
|
361
|
+
#
|
362
|
+
# @return [Net::HTTP]
|
363
|
+
# The HTTP session object.
|
364
|
+
#
|
365
|
+
# @api public
|
366
|
+
#
|
367
|
+
def http_connect(options={},&block)
|
368
|
+
options = HTTP.expand_options(options)
|
369
|
+
|
370
|
+
host = options[:host].to_s
|
371
|
+
port = options[:port]
|
372
|
+
proxy = options[:proxy]
|
373
|
+
proxy_host = if (proxy && proxy[:host])
|
374
|
+
proxy[:host].to_s
|
375
|
+
end
|
376
|
+
|
377
|
+
sess = Net::HTTP::Proxy(
|
378
|
+
proxy_host,
|
379
|
+
proxy[:port],
|
380
|
+
proxy[:user],
|
381
|
+
proxy[:password]
|
382
|
+
).new(host.to_s,port)
|
383
|
+
|
384
|
+
if options[:ssl]
|
385
|
+
sess.use_ssl = true
|
386
|
+
sess.verify_mode = SSL::VERIFY[options[:ssl][:verify]]
|
387
|
+
end
|
388
|
+
|
389
|
+
sess.start()
|
390
|
+
|
391
|
+
if block
|
392
|
+
if block.arity == 2
|
393
|
+
block.call(sess,options)
|
394
|
+
else
|
395
|
+
block.call(sess)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
return sess
|
400
|
+
end
|
401
|
+
|
402
|
+
#
|
403
|
+
# Creates a new temporary HTTP session with the server.
|
404
|
+
#
|
405
|
+
# @param [Hash] options
|
406
|
+
# Additional options
|
407
|
+
#
|
408
|
+
# @option options [String, URI::HTTP] :url
|
409
|
+
# The full URL to request.
|
410
|
+
#
|
411
|
+
# @option options [String] :host
|
412
|
+
# The host the HTTP server is running on.
|
413
|
+
#
|
414
|
+
# @option options [Integer] :port (Net::HTTP.default_port)
|
415
|
+
# The port the HTTP server is listening on.
|
416
|
+
#
|
417
|
+
# @option options [String] :user
|
418
|
+
# The user to authenticate with when connecting to the HTTP server.
|
419
|
+
#
|
420
|
+
# @option options [String] :password
|
421
|
+
# The password to authenticate with when connecting to the HTTP server.
|
422
|
+
#
|
423
|
+
# @option options [String, Hash] :proxy (HTTP.proxy)
|
424
|
+
# A Hash of proxy settings to use when connecting to the HTTP server.
|
425
|
+
#
|
426
|
+
# @option options [Boolean, Hash] :ssl
|
427
|
+
# Enables SSL for the HTTP connection.
|
428
|
+
#
|
429
|
+
# @option :ssl [Symbol] :verify
|
430
|
+
# Specifies the SSL certificate verification mode.
|
431
|
+
#
|
432
|
+
# @yield [session]
|
433
|
+
# If a block is given, it will be passed the newly created HTTP
|
434
|
+
# session object.
|
435
|
+
#
|
436
|
+
# @yieldparam [Net::HTTP] session
|
437
|
+
# The newly created HTTP session.
|
438
|
+
#
|
439
|
+
# @return [nil]
|
440
|
+
#
|
441
|
+
# @see http_connect
|
442
|
+
#
|
443
|
+
# @api public
|
444
|
+
#
|
445
|
+
def http_session(options={},&block)
|
446
|
+
http_connect(options) do |sess,expanded_options|
|
447
|
+
if block
|
448
|
+
if block.arity == 2
|
449
|
+
block.call(sess,expanded_options)
|
450
|
+
else
|
451
|
+
block.call(sess)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
sess.finish
|
456
|
+
end
|
457
|
+
|
458
|
+
return nil
|
459
|
+
end
|
460
|
+
|
461
|
+
#
|
462
|
+
# Connects to the HTTP server and sends an HTTP Request.
|
463
|
+
#
|
464
|
+
# @param [Hash] options
|
465
|
+
# Additional options.
|
466
|
+
#
|
467
|
+
# @option options [Symbol, String] :method
|
468
|
+
# The HTTP method to use in the request.
|
469
|
+
#
|
470
|
+
# @option options [String] :path
|
471
|
+
# The path to request from the HTTP server.
|
472
|
+
#
|
473
|
+
# @option options [Hash] :headers
|
474
|
+
# The Hash of the HTTP headers to send with the request.
|
475
|
+
# May contain either Strings or Symbols, lower-case or camel-case keys.
|
476
|
+
#
|
477
|
+
# @option options [String] :body
|
478
|
+
# The body of the request.
|
479
|
+
#
|
480
|
+
# @option options [Hash, String] :form_data
|
481
|
+
# The form data that may be sent in the body of the request.
|
482
|
+
#
|
483
|
+
# @yield [request, (options)]
|
484
|
+
# If a block is given, it will be passed the HTTP request object.
|
485
|
+
# If the block has an arity of 2, it will also be passed the expanded
|
486
|
+
# version of the given _options_.
|
487
|
+
#
|
488
|
+
# @yieldparam [Net::HTTP::Request] request
|
489
|
+
# The HTTP request object to use in the request.
|
490
|
+
#
|
491
|
+
# @yieldparam [Hash] options
|
492
|
+
# The expanded version of the given _options_.
|
493
|
+
#
|
494
|
+
# @return [Net::HTTP::Response]
|
495
|
+
# The response of the HTTP request.
|
496
|
+
#
|
497
|
+
# @see http_session
|
498
|
+
#
|
499
|
+
# @api public
|
500
|
+
#
|
501
|
+
def http_request(options={},&block)
|
502
|
+
resp = nil
|
503
|
+
|
504
|
+
http_session(options) do |http,expanded_options|
|
505
|
+
req = HTTP.request(expanded_options)
|
506
|
+
|
507
|
+
if block
|
508
|
+
if block.arity == 2
|
509
|
+
block.call(req,expanded_options)
|
510
|
+
else
|
511
|
+
block.call(req)
|
512
|
+
end
|
513
|
+
end
|
514
|
+
|
515
|
+
resp = http.request(req)
|
516
|
+
end
|
517
|
+
|
518
|
+
return resp
|
519
|
+
end
|
520
|
+
|
521
|
+
#
|
522
|
+
# Returns the Status Code of the Response.
|
523
|
+
#
|
524
|
+
# @param [Hash] options
|
525
|
+
# Additional options.
|
526
|
+
#
|
527
|
+
# @option options [Symbol, String] :method (:head)
|
528
|
+
# The method to use for the request.
|
529
|
+
#
|
530
|
+
# @return [Integer]
|
531
|
+
# The HTTP Response Status.
|
532
|
+
#
|
533
|
+
# @see http_request
|
534
|
+
#
|
535
|
+
# @since 0.2.0
|
536
|
+
#
|
537
|
+
# @api public
|
538
|
+
#
|
539
|
+
def http_status(options={})
|
540
|
+
options = {:method => :head}.merge(options)
|
541
|
+
|
542
|
+
return http_request(options).code.to_i
|
543
|
+
end
|
544
|
+
|
545
|
+
#
|
546
|
+
# Checks if the response has an HTTP OK status code.
|
547
|
+
#
|
548
|
+
# @param [Hash] options
|
549
|
+
# Additional options.
|
550
|
+
#
|
551
|
+
# @option options [Symbol, String] :method (:head)
|
552
|
+
# The method to use for the request.
|
553
|
+
#
|
554
|
+
# @return [Boolean]
|
555
|
+
# Specifies whether the response had an HTTP OK status code or not.
|
556
|
+
#
|
557
|
+
# @see http_status
|
558
|
+
#
|
559
|
+
# @api public
|
560
|
+
#
|
561
|
+
def http_ok?(options={})
|
562
|
+
http_status(options) == 200
|
563
|
+
end
|
564
|
+
|
565
|
+
#
|
566
|
+
# Sends a HTTP Head request and returns the HTTP Server header.
|
567
|
+
#
|
568
|
+
# @param [Hash] options
|
569
|
+
# Additional options.
|
570
|
+
#
|
571
|
+
# @option options [Symbol, String] :method (:head)
|
572
|
+
# The method to use for the request.
|
573
|
+
#
|
574
|
+
# @return [String]
|
575
|
+
# The HTTP `Server` header.
|
576
|
+
#
|
577
|
+
# @see http_request
|
578
|
+
#
|
579
|
+
# @api public
|
580
|
+
#
|
581
|
+
def http_server(options={})
|
582
|
+
options = {:method => :head}.merge(options)
|
583
|
+
|
584
|
+
return http_request(options)['server']
|
585
|
+
end
|
586
|
+
|
587
|
+
#
|
588
|
+
# Sends an HTTP Head request and returns the HTTP X-Powered-By header.
|
589
|
+
#
|
590
|
+
# @param [Hash] options
|
591
|
+
# Additional options.
|
592
|
+
#
|
593
|
+
# @option options [Symbol, String] :method (:get)
|
594
|
+
# The method to use for the request.
|
595
|
+
#
|
596
|
+
# @return [String]
|
597
|
+
# The HTTP `X-Powered-By` header.
|
598
|
+
#
|
599
|
+
# @see http_request
|
600
|
+
#
|
601
|
+
# @api public
|
602
|
+
#
|
603
|
+
def http_powered_by(options={})
|
604
|
+
options = {:method => :get}.merge(options)
|
605
|
+
|
606
|
+
return http_request(options)['x-powered-by']
|
607
|
+
end
|
608
|
+
|
609
|
+
#
|
610
|
+
# Performs an HTTP Copy request.
|
611
|
+
#
|
612
|
+
# @param [Hash] options
|
613
|
+
# Additional options.
|
614
|
+
#
|
615
|
+
# @yield [response]
|
616
|
+
# If a block is given, it will be passed the response received
|
617
|
+
# from the request.
|
618
|
+
#
|
619
|
+
# @yieldparam [Net::HTTP::Response] response
|
620
|
+
# The HTTP response object.
|
621
|
+
#
|
622
|
+
# @return [Net::HTTP::Response]
|
623
|
+
# The response of the HTTP request.
|
624
|
+
#
|
625
|
+
# @see http_request
|
626
|
+
#
|
627
|
+
# @api public
|
628
|
+
#
|
629
|
+
def http_copy(options={})
|
630
|
+
resp = http_request(options.merge(:method => :copy))
|
631
|
+
|
632
|
+
yield resp if block_given?
|
633
|
+
return resp
|
634
|
+
end
|
635
|
+
|
636
|
+
#
|
637
|
+
# Performs an HTTP Delete request.
|
638
|
+
#
|
639
|
+
# @param [Hash] options
|
640
|
+
# Additional options.
|
641
|
+
#
|
642
|
+
# @yield [response]
|
643
|
+
# If a block is given, it will be passed the response received from
|
644
|
+
# the request.
|
645
|
+
#
|
646
|
+
# @yieldparam [Net::HTTP::Response] response
|
647
|
+
# The HTTP response object.
|
648
|
+
#
|
649
|
+
# @return [Net::HTTP::Response]
|
650
|
+
# The response of the HTTP request.
|
651
|
+
#
|
652
|
+
# @see http_request
|
653
|
+
#
|
654
|
+
# @api public
|
655
|
+
#
|
656
|
+
def http_delete(options={},&block)
|
657
|
+
original_headers = options[:headers]
|
658
|
+
|
659
|
+
# set the HTTP Depth header
|
660
|
+
options[:headers] = {:depth => 'Infinity'}
|
661
|
+
|
662
|
+
if original_headers
|
663
|
+
options[:header].merge!(original_headers)
|
664
|
+
end
|
665
|
+
|
666
|
+
resp = http_request(options.merge(:method => :delete))
|
667
|
+
|
668
|
+
yield resp if block_given?
|
669
|
+
return resp
|
670
|
+
end
|
671
|
+
|
672
|
+
#
|
673
|
+
# Performs an HTTP Get request.
|
674
|
+
#
|
675
|
+
# @param [Hash] options
|
676
|
+
# Additional options.
|
677
|
+
#
|
678
|
+
# @yield [response]
|
679
|
+
# If a block is given, it will be passed the response received from
|
680
|
+
# the request.
|
681
|
+
#
|
682
|
+
# @yieldparam [Net::HTTP::Response] response
|
683
|
+
# The HTTP response object.
|
684
|
+
#
|
685
|
+
# @return [Net::HTTP::Response]
|
686
|
+
# The response of the HTTP request.
|
687
|
+
#
|
688
|
+
# @see http_request
|
689
|
+
#
|
690
|
+
# @api public
|
691
|
+
#
|
692
|
+
def http_get(options={},&block)
|
693
|
+
resp = http_request(options.merge(:method => :get))
|
694
|
+
|
695
|
+
yield resp if block_given?
|
696
|
+
return resp
|
697
|
+
end
|
698
|
+
|
699
|
+
#
|
700
|
+
# Performs an HTTP Get request and returns the Response Headers.
|
701
|
+
#
|
702
|
+
# @param [Hash] options
|
703
|
+
# Additional options.
|
704
|
+
#
|
705
|
+
# @return [Hash{String => Array<String>}]
|
706
|
+
# The Headers of the HTTP response.
|
707
|
+
#
|
708
|
+
# @see http_get
|
709
|
+
#
|
710
|
+
# @since 0.2.0
|
711
|
+
#
|
712
|
+
# @api public
|
713
|
+
#
|
714
|
+
def http_get_headers(options={})
|
715
|
+
http_get(options).to_hash
|
716
|
+
end
|
717
|
+
|
718
|
+
#
|
719
|
+
# Performs an HTTP Get request and returns the Respond Body.
|
720
|
+
#
|
721
|
+
# @param [Hash] options
|
722
|
+
# Additional options.
|
723
|
+
#
|
724
|
+
# @return [String]
|
725
|
+
# The body of the HTTP response.
|
726
|
+
#
|
727
|
+
# @see http_get
|
728
|
+
#
|
729
|
+
# @api public
|
730
|
+
#
|
731
|
+
def http_get_body(options={})
|
732
|
+
http_get(options).body
|
733
|
+
end
|
734
|
+
|
735
|
+
#
|
736
|
+
# Performs an HTTP Head request.
|
737
|
+
#
|
738
|
+
# @param [Hash] options
|
739
|
+
# Additional options.
|
740
|
+
#
|
741
|
+
# @yield [response]
|
742
|
+
# If a block is given, it will be passed the response received from
|
743
|
+
# the request.
|
744
|
+
#
|
745
|
+
# @yieldparam [Net::HTTP::Response] response
|
746
|
+
# The HTTP response object.
|
747
|
+
#
|
748
|
+
# @return [Net::HTTP::Response]
|
749
|
+
# The response of the HTTP request.
|
750
|
+
#
|
751
|
+
# @see http_request
|
752
|
+
#
|
753
|
+
# @api public
|
754
|
+
#
|
755
|
+
def http_head(options={},&block)
|
756
|
+
resp = http_request(options.merge(:method => :head))
|
757
|
+
|
758
|
+
yield resp if block_given?
|
759
|
+
return resp
|
760
|
+
end
|
761
|
+
|
762
|
+
#
|
763
|
+
# Performs an HTTP Lock request.
|
764
|
+
#
|
765
|
+
# @param [Hash] options
|
766
|
+
# Additional options.
|
767
|
+
#
|
768
|
+
# @yield [response]
|
769
|
+
# If a block is given, it will be passed the response received from
|
770
|
+
# the request.
|
771
|
+
#
|
772
|
+
# @yieldparam [Net::HTTP::Response] response
|
773
|
+
# The HTTP response object.
|
774
|
+
#
|
775
|
+
# @return [Net::HTTP::Response]
|
776
|
+
# The response of the HTTP request.
|
777
|
+
#
|
778
|
+
# @see http_request
|
779
|
+
#
|
780
|
+
# @api public
|
781
|
+
#
|
782
|
+
def http_lock(options={},&block)
|
783
|
+
resp = http_request(options.merge(:method => :lock))
|
784
|
+
|
785
|
+
yield resp if block_given?
|
786
|
+
return resp
|
787
|
+
end
|
788
|
+
|
789
|
+
#
|
790
|
+
# Performs an HTTP Mkcol request.
|
791
|
+
#
|
792
|
+
# @param [Hash] options
|
793
|
+
# Additional options.
|
794
|
+
#
|
795
|
+
# @yield [response]
|
796
|
+
# If a block is given, it will be passed the response received from
|
797
|
+
# the request.
|
798
|
+
#
|
799
|
+
# @yieldparam [Net::HTTP::Response] response
|
800
|
+
# The HTTP response object.
|
801
|
+
#
|
802
|
+
# @return [Net::HTTP::Response]
|
803
|
+
# The response of the HTTP request.
|
804
|
+
#
|
805
|
+
# @see http_request
|
806
|
+
#
|
807
|
+
# @api public
|
808
|
+
#
|
809
|
+
def http_mkcol(options={},&block)
|
810
|
+
resp = http_request(options.merge(:method => :mkcol))
|
811
|
+
|
812
|
+
yield resp if block_given?
|
813
|
+
return resp
|
814
|
+
end
|
815
|
+
|
816
|
+
#
|
817
|
+
# Performs an HTTP Move request.
|
818
|
+
#
|
819
|
+
# @param [Hash] options
|
820
|
+
# Additional options.
|
821
|
+
#
|
822
|
+
# @yield [response]
|
823
|
+
# If a block is given, it will be passed the response received from
|
824
|
+
# the request.
|
825
|
+
#
|
826
|
+
# @yieldparam [Net::HTTP::Response] response
|
827
|
+
# The HTTP response object.
|
828
|
+
#
|
829
|
+
# @return [Net::HTTP::Response]
|
830
|
+
# The response of the HTTP request.
|
831
|
+
#
|
832
|
+
# @see http_request
|
833
|
+
#
|
834
|
+
# @api public
|
835
|
+
#
|
836
|
+
def http_move(options={},&block)
|
837
|
+
resp = http_request(options.merge(:method => :move))
|
838
|
+
|
839
|
+
yield resp if block_given?
|
840
|
+
return resp
|
841
|
+
end
|
842
|
+
|
843
|
+
#
|
844
|
+
# Performs an HTTP Options request.
|
845
|
+
#
|
846
|
+
# @param [Hash] options
|
847
|
+
# Additional options.
|
848
|
+
#
|
849
|
+
# @yield [response]
|
850
|
+
# If a block is given, it will be passed the response received from
|
851
|
+
# the request.
|
852
|
+
#
|
853
|
+
# @yieldparam [Net::HTTP::Response] response
|
854
|
+
# The HTTP response object.
|
855
|
+
#
|
856
|
+
# @return [Net::HTTP::Response]
|
857
|
+
# The response of the HTTP request.
|
858
|
+
#
|
859
|
+
# @see http_request
|
860
|
+
#
|
861
|
+
# @api public
|
862
|
+
#
|
863
|
+
def http_options(options={},&block)
|
864
|
+
resp = http_request(options.merge(:method => :options))
|
865
|
+
|
866
|
+
yield resp if block_given?
|
867
|
+
return resp
|
868
|
+
end
|
869
|
+
|
870
|
+
#
|
871
|
+
# Performs an HTTP Post request.
|
872
|
+
#
|
873
|
+
# @param [Hash] options
|
874
|
+
# Additional options.
|
875
|
+
#
|
876
|
+
# @option options [Hash, String] :form_data
|
877
|
+
# The form data to send with the HTTP Post request.
|
878
|
+
#
|
879
|
+
# @yield [response]
|
880
|
+
# If a block is given, it will be passed the response received from
|
881
|
+
# the request.
|
882
|
+
#
|
883
|
+
# @yieldparam [Net::HTTP::Response] response
|
884
|
+
# The HTTP response object.
|
885
|
+
#
|
886
|
+
# @return [Net::HTTP::Response]
|
887
|
+
# The response of the HTTP request.
|
888
|
+
#
|
889
|
+
# @see http_request
|
890
|
+
#
|
891
|
+
# @api public
|
892
|
+
#
|
893
|
+
def http_post(options={},&block)
|
894
|
+
resp = http_request(options.merge(:method => :post))
|
895
|
+
|
896
|
+
yield resp if block_given?
|
897
|
+
return resp
|
898
|
+
end
|
899
|
+
|
900
|
+
#
|
901
|
+
# Performs an HTTP Post request and returns the Response Headers.
|
902
|
+
#
|
903
|
+
# @param [Hash] options
|
904
|
+
# Additional options.
|
905
|
+
#
|
906
|
+
# @option options [Hash, String] :form_data
|
907
|
+
# The form data to send with the HTTP Post request.
|
908
|
+
#
|
909
|
+
# @return [Hash{String => Array<String>}]
|
910
|
+
# The headers of the HTTP response.
|
911
|
+
#
|
912
|
+
# @see http_post
|
913
|
+
#
|
914
|
+
# @since 0.2.0
|
915
|
+
#
|
916
|
+
# @api public
|
917
|
+
#
|
918
|
+
def http_post_headers(options={})
|
919
|
+
http_post(options).to_hash
|
920
|
+
end
|
921
|
+
|
922
|
+
#
|
923
|
+
# Performs an HTTP Post request and returns the Response Body.
|
924
|
+
#
|
925
|
+
# @param [Hash] options
|
926
|
+
# Additional options.
|
927
|
+
#
|
928
|
+
# @option options [Hash, String] :form_data
|
929
|
+
# The form data to send with the HTTP Post request.
|
930
|
+
#
|
931
|
+
# @return [String]
|
932
|
+
# The body of the HTTP response.
|
933
|
+
#
|
934
|
+
# @see http_post
|
935
|
+
#
|
936
|
+
# @api public
|
937
|
+
#
|
938
|
+
def http_post_body(options={})
|
939
|
+
http_post(options).body
|
940
|
+
end
|
941
|
+
|
942
|
+
#
|
943
|
+
# Performs an HTTP Propfind request.
|
944
|
+
#
|
945
|
+
# @param [Hash] options
|
946
|
+
# Additional options.
|
947
|
+
#
|
948
|
+
# @yield [response]
|
949
|
+
# If a block is given, it will be passed the response received from
|
950
|
+
# the request.
|
951
|
+
#
|
952
|
+
# @yieldparam [Net::HTTP::Response] response
|
953
|
+
# The HTTP response object.
|
954
|
+
#
|
955
|
+
# @return [Net::HTTP::Response]
|
956
|
+
# The response of the HTTP request.
|
957
|
+
#
|
958
|
+
# @see http_request
|
959
|
+
#
|
960
|
+
# @api public
|
961
|
+
#
|
962
|
+
def http_prop_find(options={},&block)
|
963
|
+
original_headers = options[:headers]
|
964
|
+
|
965
|
+
# set the HTTP Depth header
|
966
|
+
options[:headers] = {:depth => '0'}
|
967
|
+
|
968
|
+
if original_headers
|
969
|
+
options[:header].merge!(original_headers)
|
970
|
+
end
|
971
|
+
|
972
|
+
resp = http_request(options.merge(:method => :propfind))
|
973
|
+
|
974
|
+
yield resp if block_given?
|
975
|
+
return resp
|
976
|
+
end
|
977
|
+
|
978
|
+
#
|
979
|
+
# Performs an HTTP Proppatch request.
|
980
|
+
#
|
981
|
+
# @param [Hash] options
|
982
|
+
# Additional options.
|
983
|
+
#
|
984
|
+
# @yield [response]
|
985
|
+
# If a block is given, it will be passed the response received from
|
986
|
+
# the request.
|
987
|
+
#
|
988
|
+
# @yieldparam [Net::HTTP::Response] response
|
989
|
+
# The HTTP response object.
|
990
|
+
#
|
991
|
+
# @return [Net::HTTP::Response]
|
992
|
+
# The response of the HTTP request.
|
993
|
+
#
|
994
|
+
# @see http_request
|
995
|
+
#
|
996
|
+
# @api public
|
997
|
+
#
|
998
|
+
def http_prop_patch(options={},&block)
|
999
|
+
resp = http_request(options.merge(:method => :proppatch))
|
1000
|
+
|
1001
|
+
yield resp if block_given?
|
1002
|
+
return resp
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
#
|
1006
|
+
# Performs an HTTP Trace request.
|
1007
|
+
#
|
1008
|
+
# @param [Hash] options
|
1009
|
+
# Additional options.
|
1010
|
+
#
|
1011
|
+
# @yield [response]
|
1012
|
+
# If a block is given, it will be passed the response received from
|
1013
|
+
# the request.
|
1014
|
+
#
|
1015
|
+
# @yieldparam [Net::HTTP::Response] response
|
1016
|
+
# The HTTP response object.
|
1017
|
+
#
|
1018
|
+
# @return [Net::HTTP::Response]
|
1019
|
+
# The response of the HTTP request.
|
1020
|
+
#
|
1021
|
+
# @see http_request
|
1022
|
+
#
|
1023
|
+
# @api public
|
1024
|
+
#
|
1025
|
+
def http_trace(options={},&block)
|
1026
|
+
resp = http_request(options.merge(:method => :trace))
|
1027
|
+
|
1028
|
+
yield resp if block_given?
|
1029
|
+
return resp
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
#
|
1033
|
+
# Performs an HTTP Unlock request.
|
1034
|
+
#
|
1035
|
+
# @param [Hash] options
|
1036
|
+
# Additional options.
|
1037
|
+
#
|
1038
|
+
# @yield [response]
|
1039
|
+
# If a block is given, it will be passed the response received from
|
1040
|
+
# the request.
|
1041
|
+
#
|
1042
|
+
# @yieldparam [Net::HTTP::Response] response
|
1043
|
+
# The HTTP response object.
|
1044
|
+
#
|
1045
|
+
# @return [Net::HTTP::Response]
|
1046
|
+
# The response of the HTTP request.
|
1047
|
+
#
|
1048
|
+
# @see http_request
|
1049
|
+
#
|
1050
|
+
# @api public
|
1051
|
+
#
|
1052
|
+
def http_unlock(options={},&block)
|
1053
|
+
resp = http_request(options.merge(:method => :unlock))
|
1054
|
+
|
1055
|
+
yield resp if block_given?
|
1056
|
+
return resp
|
1057
|
+
end
|
313
1058
|
end
|
314
1059
|
end
|
315
1060
|
end
|