mechanize 2.7.3 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mechanize might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +15 -0
- data/.travis.yml +5 -6
- data/CHANGELOG.rdoc +22 -0
- data/EXAMPLES.rdoc +1 -1
- data/Gemfile +3 -0
- data/Manifest.txt +0 -1
- data/README.rdoc +11 -17
- data/Rakefile +22 -38
- data/examples/{rubyforge.rb → rubygems.rb} +5 -4
- data/lib/mechanize.rb +72 -31
- data/lib/mechanize/directory_saver.rb +14 -2
- data/lib/mechanize/element_matcher.rb +24 -13
- data/lib/mechanize/file_response.rb +1 -3
- data/lib/mechanize/form.rb +8 -2
- data/lib/mechanize/http/agent.rb +38 -30
- data/lib/mechanize/http/auth_store.rb +2 -0
- data/lib/mechanize/http/www_authenticate_parser.rb +1 -1
- data/lib/mechanize/page.rb +162 -54
- data/lib/mechanize/page/image.rb +2 -0
- data/lib/mechanize/page/link.rb +5 -0
- data/lib/mechanize/pluggable_parsers.rb +13 -1
- data/lib/mechanize/test_case.rb +5 -0
- data/lib/mechanize/unsupported_scheme_error.rb +4 -2
- data/lib/mechanize/util.rb +88 -43
- data/lib/mechanize/version.rb +3 -0
- data/mechanize.gemspec +61 -0
- data/test/test_mechanize.rb +55 -41
- data/test/test_mechanize_form.rb +19 -0
- data/test/test_mechanize_form_encoding.rb +2 -7
- data/test/test_mechanize_http_agent.rb +61 -12
- data/test/test_mechanize_http_www_authenticate_parser.rb +8 -0
- data/test/test_mechanize_link.rb +14 -1
- data/test/test_mechanize_page.rb +53 -6
- data/test/test_mechanize_page_encoding.rb +2 -3
- data/test/test_mechanize_page_link.rb +17 -2
- data/test/test_mechanize_util.rb +45 -10
- metadata +147 -72
- data/.gemtest +0 -0
- data/lib/mechanize/monkey_patch.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f74b81c4883e990cd6360ee0294a3ff1ae1c8d59
|
4
|
+
data.tar.gz: 872ab6eeda86c290a94105a730bfec64ee819493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96dc6beaa52babf27369eb8548733298782a2409f7a2bb43c9a5e9241445d96e117c54ad5b8c3e445b6b4c4ea1edb37f8b223b0513916f8be7b591fa3e29c598
|
7
|
+
data.tar.gz: 95e653b7705518a33aa5bbb765be7ddc4603756e0ee24bd5ab6c2979d039ea5b29e94ae9a2b8e478ceaa993b165d83a65d695212fa271ab59889fe7c811c876d
|
data/.gitignore
ADDED
data/.travis.yml
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
---
|
2
|
-
after_script:
|
3
|
-
- rake travis:after -t
|
4
|
-
before_script:
|
5
|
-
- gem install hoe-travis --no-rdoc --no-ri
|
6
|
-
- rake travis:before -t
|
7
2
|
language: ruby
|
8
3
|
notifications:
|
9
4
|
email:
|
10
5
|
- drbrain@segment7.net
|
11
6
|
- ljjarvis@gmail.com
|
12
7
|
- knu@idaemons.org
|
8
|
+
sudo: false
|
13
9
|
rvm:
|
14
10
|
- 1.9.3
|
15
11
|
- 2.0.0
|
12
|
+
- 2.1
|
13
|
+
- 2.2
|
14
|
+
- 2.3
|
16
15
|
- ruby-head
|
17
16
|
- jruby-19mode
|
18
17
|
- jruby-head
|
19
18
|
- rbx-19mode
|
20
|
-
script: rake
|
19
|
+
script: rake test
|
21
20
|
matrix:
|
22
21
|
allow_failures:
|
23
22
|
- rvm: ruby-head
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
= Mechanize CHANGELOG
|
2
2
|
|
3
|
+
=== 2.7.4
|
4
|
+
|
5
|
+
* New Features
|
6
|
+
* Accept array-like and hash-like values as query/parameter value.
|
7
|
+
A new utility method Mechanize::Util.each_parameter is added, and Mechanize::Util.build_query_string is enhanced
|
8
|
+
for this feature.
|
9
|
+
* Allow passing a `Form::FileUpload` instance to `#post`. #350 by Sam
|
10
|
+
Rawlins.
|
11
|
+
* Capture link when scheme is unsupported. #362 by Jon Rowe.
|
12
|
+
* Pre-defined User-Agent stings are updated to those of more recent versions, and new aliases for IE 10/11 and Edge are added.
|
13
|
+
* Support for mime-types 1.x is restored while keeping compatible with mime-types 2.x and adding support for 3.0.
|
14
|
+
* Mechanize::Page now responds to #xpath, #css, #at_xpath, #at_css, and #%.
|
15
|
+
* element(s)_with methods now accept :xpath and :css options for doing xpath/css
|
16
|
+
selector searching.
|
17
|
+
* Pass URI information to Nokogiri where applicable. #405 @lulalala
|
18
|
+
|
19
|
+
* Bug fix
|
20
|
+
* Don't raise an exception if a connection has set a {read,open}_timeout and
|
21
|
+
a `file://` request is made. (#397)
|
22
|
+
* Fix whitespace bug in WWW-Authenticate. #451, #450, by Rasmus Bergholdt
|
23
|
+
* Don't allow redirect from a non-file URL to a file URL for security reasons. (#455)
|
24
|
+
|
3
25
|
=== 2.7.3
|
4
26
|
|
5
27
|
* New Features
|
data/EXAMPLES.rdoc
CHANGED
@@ -15,7 +15,7 @@ example, <code>do ... end.submit</code> is the same as <code>{ ...
|
|
15
15
|
}
|
16
16
|
|
17
17
|
a.get('http://google.com/') do |page|
|
18
|
-
search_result = page.form_with(:
|
18
|
+
search_result = page.form_with(:id => 'gbqf') do |search|
|
19
19
|
search.q = 'Hello world'
|
20
20
|
end.submit
|
21
21
|
|
data/Gemfile
ADDED
data/Manifest.txt
CHANGED
@@ -53,7 +53,6 @@ lib/mechanize/http/auth_store.rb
|
|
53
53
|
lib/mechanize/http/content_disposition_parser.rb
|
54
54
|
lib/mechanize/http/www_authenticate_parser.rb
|
55
55
|
lib/mechanize/image.rb
|
56
|
-
lib/mechanize/monkey_patch.rb
|
57
56
|
lib/mechanize/page.rb
|
58
57
|
lib/mechanize/page/base.rb
|
59
58
|
lib/mechanize/page/frame.rb
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
= Mechanize {<img src="https://secure.travis-ci.org/sparklemotion/mechanize.
|
1
|
+
= Mechanize {<img src="https://secure.travis-ci.org/sparklemotion/mechanize.svg?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/mechanize]
|
2
2
|
|
3
|
-
* http://
|
3
|
+
* http://docs.seattlerb.org/mechanize
|
4
4
|
* https://github.com/sparklemotion/mechanize
|
5
5
|
|
6
6
|
== Description
|
@@ -14,32 +14,26 @@ a history.
|
|
14
14
|
== Dependencies
|
15
15
|
|
16
16
|
* ruby 1.9.2 or newer
|
17
|
-
* nokogiri[
|
17
|
+
* nokogiri[https://github.com/sparklemotion/nokogiri]
|
18
18
|
|
19
19
|
== Support:
|
20
20
|
|
21
|
-
The mechanize mailing list is available here:
|
22
|
-
|
23
|
-
* http://rubyforge.org/mailman/listinfo/mechanize-users
|
24
|
-
|
25
21
|
The bug tracker is available here:
|
26
22
|
|
27
23
|
* https://github.com/sparklemotion/mechanize/issues
|
28
24
|
|
29
25
|
== Examples
|
30
26
|
|
31
|
-
If you are just starting, check out the GUIDE[http://
|
32
|
-
the EXAMPLES[http://
|
27
|
+
If you are just starting, check out the GUIDE[http://docs.seattlerb.org/mechanize/GUIDE_rdoc.html] or
|
28
|
+
the EXAMPLES[http://docs.seattlerb.org/mechanize/EXAMPLES_rdoc.html] file.
|
33
29
|
|
34
30
|
== Developers
|
35
31
|
|
36
|
-
|
32
|
+
Use bundler to install dependencies:
|
37
33
|
|
38
|
-
|
39
|
-
rake newb
|
34
|
+
bundle install
|
40
35
|
|
41
|
-
|
42
|
-
subsequent test runs:
|
36
|
+
Run all tests with:
|
43
37
|
|
44
38
|
rake test
|
45
39
|
|
@@ -57,11 +51,11 @@ Copyright (c) 2006-2011:
|
|
57
51
|
* {Aaron Patterson}[http://tenderlovemaking.com] (aaronp@rubyforge.org)
|
58
52
|
* {Mike Dalessio}[http://mike.daless.io] (mike@csa.net)
|
59
53
|
|
60
|
-
Copyright (c) 2011-
|
54
|
+
Copyright (c) 2011-2015:
|
61
55
|
|
62
56
|
* {Eric Hodel}[http://blog.segment7.net] (drbrain@segment7.net)
|
63
57
|
* {Akinori MUSHA}[http://blog.akinori.org] (knu@idaemons.org)
|
64
|
-
* {Lee Jarvis}[http://
|
58
|
+
* {Lee Jarvis}[http://twitter.com/lee_jarvis] (ljjarvis@gmail.com)
|
65
59
|
|
66
60
|
This library comes with a shameless plug for employing me
|
67
61
|
(Aaron[http://tenderlovemaking.com/]) programming Ruby, my favorite language!
|
@@ -79,5 +73,5 @@ library!
|
|
79
73
|
|
80
74
|
== License
|
81
75
|
|
82
|
-
This library is distributed under the MIT license. Please see the LICENSE[http://
|
76
|
+
This library is distributed under the MIT license. Please see the LICENSE[http://docs.seattlerb.org/mechanize/LICENSE_rdoc.html] file.
|
83
77
|
|
data/Rakefile
CHANGED
@@ -1,38 +1,14 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'hoe'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
hoe = Hoe.spec 'mechanize' do
|
9
|
-
developer 'Eric Hodel', 'drbrain@segment7.net'
|
10
|
-
developer 'Aaron Patterson', 'aaronp@rubyforge.org'
|
11
|
-
developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
|
12
|
-
developer 'Akinori MUSHA', 'knu@idaemons.org'
|
13
|
-
developer 'Lee Jarvis', 'ljjarvis@gmail.com'
|
14
|
-
|
15
|
-
self.readme_file = 'README.rdoc'
|
16
|
-
self.history_file = 'CHANGELOG.rdoc'
|
17
|
-
self.extra_rdoc_files += Dir['*.rdoc']
|
18
|
-
|
19
|
-
rdoc_locations << 'rubyforge.org:/var/www/gforge-projects/mechanize/'
|
20
|
-
|
21
|
-
self.extra_deps << ['net-http-digest_auth', '~> 1.1', '>= 1.1.1']
|
22
|
-
self.extra_deps << ['net-http-persistent', '~> 2.5', '>= 2.5.2']
|
23
|
-
self.extra_deps << ['mime-types', '~> 2.0']
|
24
|
-
self.extra_deps << ['http-cookie', '~> 1.0']
|
25
|
-
self.extra_deps << ['nokogiri', '~> 1.4']
|
26
|
-
self.extra_deps << ['ntlm-http', '~> 0.1', '>= 0.1.1']
|
27
|
-
self.extra_deps << ['webrobots', '< 0.2', '>= 0.0.9']
|
28
|
-
self.extra_deps << ['domain_name', '~> 0.5', '>= 0.5.1']
|
29
|
-
|
30
|
-
self.extra_dev_deps << ['minitest', '~> 5.0']
|
31
|
-
|
32
|
-
self.spec_extras[:required_ruby_version] = '>= 1.8.7'
|
3
|
+
begin
|
4
|
+
require "bundler/gem_tasks"
|
5
|
+
rescue LoadError
|
33
6
|
end
|
34
7
|
|
35
|
-
task
|
8
|
+
require 'rdoc/task'
|
9
|
+
require 'rake/testtask'
|
10
|
+
|
11
|
+
task :prerelease => [:clobber_rdoc, :test]
|
36
12
|
|
37
13
|
desc "Update SSL Certificate"
|
38
14
|
task('ssl_cert') do |p|
|
@@ -46,12 +22,20 @@ task('ssl_cert') do |p|
|
|
46
22
|
sh "rm server.key.org"
|
47
23
|
end
|
48
24
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
25
|
+
RDoc::Task.new do |rdoc|
|
26
|
+
rdoc.main = "README.rdoc"
|
27
|
+
rdoc.rdoc_dir = 'doc'
|
28
|
+
rdoc.rdoc_files.include( "CHANGELOG.rdoc", "EXAMPLES.rdoc", "GUIDE.rdoc", "LICENSE.rdoc", "Manifest.txt", "README.rdoc", "lib/**/*.rb")
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Run tests"
|
32
|
+
Rake::TestTask.new { |t|
|
33
|
+
t.test_files = Dir['test/**/test*.rb']
|
34
|
+
t.verbose = true
|
35
|
+
}
|
36
|
+
|
37
|
+
task publish_docs: %w[rdoc] do
|
38
|
+
sh 'rsync', '-avzO', '--delete', 'doc/', 'docs-push.seattlerb.org:/data/www/docs.seattlerb.org/mechanize/'
|
56
39
|
end
|
57
40
|
|
41
|
+
task default: :test
|
@@ -10,11 +10,12 @@ mech.log = Logger.new $stderr
|
|
10
10
|
mech.agent.http.debug_output = $stderr
|
11
11
|
|
12
12
|
# Load the rubyforge website
|
13
|
-
page = mech.get('
|
14
|
-
page = mech.click page.link_with(:text => /
|
13
|
+
page = mech.get('https://rubygems.org/')
|
14
|
+
page = mech.click page.link_with(:text => /Sign in/) # Click the login link
|
15
15
|
form = page.forms[1] # Select the first form
|
16
|
-
form
|
17
|
-
form
|
16
|
+
form["session[who]"] = ARGV[0]
|
17
|
+
form["session[password]"] = ARGV[1]
|
18
|
+
form["commit"] = "Sign in"
|
18
19
|
|
19
20
|
# Submit the form
|
20
21
|
page = form.submit form.buttons.first
|
data/lib/mechanize.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
+
require 'mechanize/version'
|
1
2
|
require 'fileutils'
|
2
3
|
require 'forwardable'
|
3
|
-
require 'iconv' if RUBY_VERSION < '1.9.2'
|
4
|
-
require 'mime/types'
|
5
4
|
require 'mutex_m'
|
6
5
|
require 'net/http/digest_auth'
|
7
6
|
require 'net/http/persistent'
|
@@ -70,11 +69,6 @@ require 'zlib'
|
|
70
69
|
|
71
70
|
class Mechanize
|
72
71
|
|
73
|
-
##
|
74
|
-
# The version of Mechanize you are using.
|
75
|
-
|
76
|
-
VERSION = '2.7.3'
|
77
|
-
|
78
72
|
##
|
79
73
|
# Base mechanize error class
|
80
74
|
|
@@ -92,22 +86,26 @@ class Mechanize
|
|
92
86
|
# description in parenthesis is for informative purposes and is not part of
|
93
87
|
# the alias name.
|
94
88
|
#
|
95
|
-
# * Linux Firefox (
|
89
|
+
# * Linux Firefox (43.0 on Ubuntu Linux)
|
96
90
|
# * Linux Konqueror (3)
|
97
91
|
# * Linux Mozilla
|
98
|
-
# * Mac Firefox (
|
92
|
+
# * Mac Firefox (43.0)
|
99
93
|
# * Mac Mozilla
|
100
|
-
# * Mac Safari (
|
94
|
+
# * Mac Safari (9.0 on OS X 10.11.2)
|
101
95
|
# * Mac Safari 4
|
102
96
|
# * Mechanize (default)
|
103
97
|
# * Windows IE 6
|
104
98
|
# * Windows IE 7
|
105
99
|
# * Windows IE 8
|
106
100
|
# * Windows IE 9
|
101
|
+
# * Windows IE 10 (Windows 8 64bit)
|
102
|
+
# * Windows IE 11 (Windows 8.1 64bit)
|
103
|
+
# * Windows Edge
|
107
104
|
# * Windows Mozilla
|
108
|
-
# *
|
109
|
-
# *
|
110
|
-
# *
|
105
|
+
# * Windows Firefox (43.0)
|
106
|
+
# * iPhone (iOS 9.1)
|
107
|
+
# * iPad (iOS 9.1)
|
108
|
+
# * Android (5.1.1)
|
111
109
|
#
|
112
110
|
# Example:
|
113
111
|
#
|
@@ -116,26 +114,37 @@ class Mechanize
|
|
116
114
|
|
117
115
|
AGENT_ALIASES = {
|
118
116
|
'Mechanize' => "Mechanize/#{VERSION} Ruby/#{ruby_version} (http://github.com/sparklemotion/mechanize/)",
|
119
|
-
'Linux Firefox' => 'Mozilla/5.0 (X11;
|
117
|
+
'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0',
|
120
118
|
'Linux Konqueror' => 'Mozilla/5.0 (compatible; Konqueror/3; Linux)',
|
121
119
|
'Linux Mozilla' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624',
|
122
|
-
'Mac Firefox' => 'Mozilla/5.0 (Macintosh;
|
120
|
+
'Mac Firefox' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0',
|
123
121
|
'Mac Mozilla' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401',
|
124
122
|
'Mac Safari 4' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-at) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10',
|
125
|
-
'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X
|
126
|
-
'Windows Chrome' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
123
|
+
'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9',
|
124
|
+
'Windows Chrome' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.125 Safari/537.36',
|
127
125
|
'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
|
128
126
|
'Windows IE 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
|
129
127
|
'Windows IE 8' => 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
|
130
128
|
'Windows IE 9' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
|
129
|
+
'Windows IE 10' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)',
|
130
|
+
'Windows IE 11' => 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
|
131
|
+
'Windows Edge' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586',
|
131
132
|
'Windows Mozilla' => 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6',
|
132
|
-
'
|
133
|
-
'
|
134
|
-
'
|
133
|
+
'Windows Firefox' => 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0',
|
134
|
+
'iPhone' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B5110e Safari/601.1',
|
135
|
+
'iPad' => 'Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
136
|
+
'Android' => 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 7 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.76 Safari/537.36',
|
135
137
|
}
|
136
138
|
|
137
|
-
AGENT_ALIASES
|
138
|
-
|
139
|
+
AGENT_ALIASES.default_proc = proc { |hash, key|
|
140
|
+
case key
|
141
|
+
when /FireFox/
|
142
|
+
if ua = hash[nkey = key.sub(/FireFox/, 'Firefox')]
|
143
|
+
warn "Mechanize#user_agent_alias: #{key.inspect} should be spelled as #{nkey.inspect}"
|
144
|
+
ua
|
145
|
+
end
|
146
|
+
end
|
147
|
+
}
|
139
148
|
|
140
149
|
def self.inherited(child) # :nodoc:
|
141
150
|
child.html_parser = html_parser
|
@@ -342,12 +351,21 @@ class Mechanize
|
|
342
351
|
click real_link
|
343
352
|
else
|
344
353
|
button = nil
|
354
|
+
# Note that this will not work if we have since navigated to a different page.
|
355
|
+
# Should rather make each button aware of its parent form.
|
345
356
|
form = page.forms.find do |f|
|
346
357
|
button = f.button_with(:value => link)
|
347
358
|
button.is_a? Form::Submit
|
348
359
|
end
|
349
360
|
submit form, button if form
|
350
361
|
end
|
362
|
+
when Form::Submit, Form::ImageButton then
|
363
|
+
# Note that this will not work if we have since navigated to a different page.
|
364
|
+
# Should rather make each button aware of its parent form.
|
365
|
+
form = page.forms.find do |f|
|
366
|
+
f.buttons.include?(link)
|
367
|
+
end
|
368
|
+
submit form, link if form
|
351
369
|
else
|
352
370
|
referer = current_page()
|
353
371
|
href = link.respond_to?(:href) ? link.href :
|
@@ -400,6 +418,9 @@ class Mechanize
|
|
400
418
|
##
|
401
419
|
# DELETE +uri+ with +query_params+, and setting +headers+:
|
402
420
|
#
|
421
|
+
# +query_params+ is formatted into a query string using
|
422
|
+
# Mechanize::Util.build_query_string, which see.
|
423
|
+
#
|
403
424
|
# delete('http://example/', {'q' => 'foo'}, {})
|
404
425
|
|
405
426
|
def delete(uri, query_params = {}, headers = {})
|
@@ -413,6 +434,9 @@ class Mechanize
|
|
413
434
|
# +headers+.
|
414
435
|
#
|
415
436
|
# The +referer+ may be a URI or a page.
|
437
|
+
#
|
438
|
+
# +parameters+ is formatted into a query string using
|
439
|
+
# Mechanize::Util.build_query_string, which see.
|
416
440
|
|
417
441
|
def get(uri, parameters = [], referer = nil, headers = {})
|
418
442
|
method = :get
|
@@ -453,6 +477,9 @@ class Mechanize
|
|
453
477
|
##
|
454
478
|
# HEAD +uri+ with +query_params+ and +headers+:
|
455
479
|
#
|
480
|
+
# +query_params+ is formatted into a query string using
|
481
|
+
# Mechanize::Util.build_query_string, which see.
|
482
|
+
#
|
456
483
|
# head('http://example/', {'q' => 'foo'}, {})
|
457
484
|
|
458
485
|
def head(uri, query_params = {}, headers = {})
|
@@ -464,9 +491,13 @@ class Mechanize
|
|
464
491
|
end
|
465
492
|
|
466
493
|
##
|
467
|
-
# POST to the given +uri+ with the given +query+.
|
468
|
-
#
|
469
|
-
#
|
494
|
+
# POST to the given +uri+ with the given +query+.
|
495
|
+
#
|
496
|
+
# +query+ is processed using Mechanize::Util.each_parameter (which
|
497
|
+
# see), and then encoded into an entity body. If any IO/FileUpload
|
498
|
+
# object is specified as a field value the "enctype" will be
|
499
|
+
# multipart/form-data, or application/x-www-form-urlencoded
|
500
|
+
# otherwise.
|
470
501
|
#
|
471
502
|
# Examples:
|
472
503
|
# agent.post 'http://example.com/', "foo" => "bar"
|
@@ -489,12 +520,15 @@ class Mechanize
|
|
489
520
|
|
490
521
|
form = Form.new(node)
|
491
522
|
|
492
|
-
query
|
523
|
+
Mechanize::Util.each_parameter(query) { |k, v|
|
493
524
|
if v.is_a?(IO)
|
494
525
|
form.enctype = 'multipart/form-data'
|
495
526
|
ul = Form::FileUpload.new({'name' => k.to_s},::File.basename(v.path))
|
496
527
|
ul.file_data = v.read
|
497
528
|
form.file_uploads << ul
|
529
|
+
elsif v.is_a?(Form::FileUpload)
|
530
|
+
form.enctype = 'multipart/form-data'
|
531
|
+
form.file_uploads << v
|
498
532
|
else
|
499
533
|
form.fields << Form::Field.new({'name' => k.to_s},v)
|
500
534
|
end
|
@@ -518,6 +552,8 @@ class Mechanize
|
|
518
552
|
def request_with_entity(verb, uri, entity, headers = {})
|
519
553
|
cur_page = current_page || Page.new
|
520
554
|
|
555
|
+
log.debug("query: #{ entity.inspect }") if log
|
556
|
+
|
521
557
|
headers = {
|
522
558
|
'Content-Type' => 'application/octet-stream',
|
523
559
|
'Content-Length' => entity.size.to_s,
|
@@ -934,6 +970,12 @@ Use of #auth and #basic_auth are deprecated due to a security vulnerability.
|
|
934
970
|
@agent.redirection_limit = limit
|
935
971
|
end
|
936
972
|
|
973
|
+
##
|
974
|
+
# Resolve the full path of a link / uri
|
975
|
+
def resolve link
|
976
|
+
@agent.resolve link
|
977
|
+
end
|
978
|
+
|
937
979
|
##
|
938
980
|
# A hash of custom request headers that will be sent on every request
|
939
981
|
|
@@ -1138,19 +1180,19 @@ Use of #auth and #basic_auth are deprecated due to a security vulnerability.
|
|
1138
1180
|
end
|
1139
1181
|
|
1140
1182
|
##
|
1141
|
-
# SSL version to use.
|
1183
|
+
# SSL version to use.
|
1142
1184
|
|
1143
1185
|
def ssl_version
|
1144
1186
|
@agent.ssl_version
|
1145
|
-
end
|
1187
|
+
end
|
1146
1188
|
|
1147
1189
|
##
|
1148
1190
|
# Sets the SSL version to use to +version+ without client/server
|
1149
|
-
# negotiation.
|
1191
|
+
# negotiation.
|
1150
1192
|
|
1151
1193
|
def ssl_version= ssl_version
|
1152
1194
|
@agent.ssl_version = ssl_version
|
1153
|
-
end
|
1195
|
+
end
|
1154
1196
|
|
1155
1197
|
##
|
1156
1198
|
# A callback for additional certificate verification. See
|
@@ -1316,7 +1358,6 @@ require 'mechanize/http/content_disposition_parser'
|
|
1316
1358
|
require 'mechanize/http/www_authenticate_parser'
|
1317
1359
|
require 'mechanize/image'
|
1318
1360
|
require 'mechanize/page'
|
1319
|
-
require 'mechanize/monkey_patch'
|
1320
1361
|
require 'mechanize/pluggable_parsers'
|
1321
1362
|
require 'mechanize/redirect_limit_reached_error'
|
1322
1363
|
require 'mechanize/redirect_not_get_or_head_error'
|