mechanize 2.1 → 2.1.1
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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.rdoc +28 -0
- data/Manifest.txt +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/examples/wikipedia_links_to_philosophy.rb +159 -0
- data/lib/mechanize.rb +68 -5
- data/lib/mechanize/download.rb +9 -8
- data/lib/mechanize/form.rb +8 -0
- data/lib/mechanize/form/field.rb +8 -0
- data/lib/mechanize/http/agent.rb +107 -65
- data/lib/mechanize/http/www_authenticate_parser.rb +14 -0
- data/lib/mechanize/page.rb +8 -10
- data/lib/mechanize/page/meta_refresh.rb +8 -1
- data/lib/mechanize/parser.rb +1 -1
- data/lib/mechanize/response_read_error.rb +15 -4
- data/lib/mechanize/test_case.rb +10 -0
- data/lib/mechanize/util.rb +23 -15
- data/test/htdocs/tc_referer.html +1 -1
- data/test/test_mechanize.rb +48 -2
- data/test/test_mechanize_download.rb +11 -1
- data/test/test_mechanize_file.rb +7 -0
- data/test/test_mechanize_form.rb +16 -1
- data/test/test_mechanize_http_agent.rb +155 -26
- data/test/test_mechanize_page_encoding.rb +6 -0
- data/test/test_mechanize_page_meta_refresh.rb +10 -0
- data/test/test_mechanize_parser.rb +10 -0
- data/test/test_mechanize_response_read_error.rb +28 -0
- data/test/test_mechanize_util.rb +5 -0
- metadata +47 -30
- metadata.gz.sig +0 -0
- data/FAQ.rdoc +0 -11
@@ -23,6 +23,12 @@ class TestMechanizePageEncoding < Mechanize::TestCase
|
|
23
23
|
def test_page_charset
|
24
24
|
charset = Mechanize::Page.charset 'text/html;charset=vAlue'
|
25
25
|
assert_equal 'vAlue', charset
|
26
|
+
|
27
|
+
charset = Mechanize::Page.charset 'text/html;charset=vaLue, text/html'
|
28
|
+
assert_equal 'vaLue', charset
|
29
|
+
|
30
|
+
charset = Mechanize::Page.charset 'text/html ; charset = valUe, text/html'
|
31
|
+
assert_equal 'valUe', charset
|
26
32
|
end
|
27
33
|
|
28
34
|
def test_page_charset_upcase
|
@@ -69,6 +69,16 @@ class TestMechanizePageMetaRefresh < Mechanize::TestCase
|
|
69
69
|
refute link_self
|
70
70
|
end
|
71
71
|
|
72
|
+
def test_class_parse_funky
|
73
|
+
delay, uri, link_self = @MR.parse "0; url=/funky?<b>Welcome<%2Fb>", @uri
|
74
|
+
|
75
|
+
assert_equal "0", delay
|
76
|
+
assert_equal "http://example/funky?%3Cb%3EWelcome%3C%2Fb%3E",
|
77
|
+
uri.to_s
|
78
|
+
|
79
|
+
refute link_self
|
80
|
+
end
|
81
|
+
|
72
82
|
def test_class_from_node
|
73
83
|
page = util_page 5, 'http://b.example'
|
74
84
|
link = util_meta_refresh page
|
@@ -37,6 +37,16 @@ class TestMechanizeParser < Mechanize::TestCase
|
|
37
37
|
assert_equal 'genome.jpeg', @parser.extract_filename
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_extract_filename_content_disposition_bad
|
41
|
+
@parser.uri = URI 'http://example/foo'
|
42
|
+
|
43
|
+
@parser.response = {
|
44
|
+
'content-disposition' => "inline; filename*=UTF-8''X%20Y.jpg"
|
45
|
+
}
|
46
|
+
|
47
|
+
assert_equal 'foo.html', @parser.extract_filename
|
48
|
+
end
|
49
|
+
|
40
50
|
def test_extract_filename_content_disposition_path
|
41
51
|
@parser.uri = URI 'http://example'
|
42
52
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'mechanize/test_case'
|
2
|
+
|
3
|
+
class TestMechanizeResponseReadError < Mechanize::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@error = 'error message'
|
9
|
+
@response = Response.new
|
10
|
+
@response['content-length'] = 3
|
11
|
+
@body_io = StringIO.new 'body'
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_force_parse
|
15
|
+
@response['content-type'] = 'text/html'
|
16
|
+
uri = URI 'http://example/'
|
17
|
+
|
18
|
+
e = Mechanize::ResponseReadError.new @error, @response, @body_io, uri, @mech
|
19
|
+
|
20
|
+
page = e.force_parse
|
21
|
+
|
22
|
+
assert_kind_of Mechanize::Page, page
|
23
|
+
assert_equal 'body', page.body
|
24
|
+
assert_equal @mech, page.mech
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
data/test/test_mechanize_util.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mechanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 2.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Eric Hodel
|
@@ -18,9 +19,9 @@ bindir: bin
|
|
18
19
|
cert_chain:
|
19
20
|
- |
|
20
21
|
-----BEGIN CERTIFICATE-----
|
21
|
-
|
22
|
+
MIIDVzCCAj+gAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdkcmJy
|
22
23
|
YWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZFgNu
|
23
|
-
|
24
|
+
ZXQwHhcNMTIwMTMxMDEwMzUyWhcNMTMwMTMwMDEwMzUyWjBBMRAwDgYDVQQDDAdk
|
24
25
|
cmJyYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZ
|
25
26
|
FgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbbgLrGLGIDE76
|
26
27
|
LV/cvxdEzCuYuS3oG9PrSZnuDweySUfdp/so0cDq+j8bqy6OzZSw07gdjwFMSd6J
|
@@ -28,17 +29,17 @@ cert_chain:
|
|
28
29
|
Gj/okWrQl0NjYOYBpDi+9PPmaH2RmLJu0dB/NylsDnW5j6yN1BEI8MfJRR+HRKZY
|
29
30
|
mUtgzBwF1V4KIZQ8EuL6I/nHVu07i6IkrpAgxpXUfdJQJi0oZAqXurAV3yTxkFwd
|
30
31
|
g62YrrW26mDe+pZBzR6bpLE+PmXCzz7UxUq3AE0gPHbiMXie3EFE0oxnsU3lIduh
|
31
|
-
|
32
|
-
BBS5k4Z75VSpdM0AclG2UvzFA/
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
sCANiQ8BAgMBAAGjWjBYMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
33
|
+
BBS5k4Z75VSpdM0AclG2UvzFA/VW5DAfBgNVHREEGDAWgRRkcmJyYWluQHNlZ21l
|
34
|
+
bnQ3Lm5ldDANBgkqhkiG9w0BAQUFAAOCAQEAge3LmAU2QbrS2/grAEmRu3bCCHrQ
|
35
|
+
NSc6j+p53VJ1DraNWEMY3D90F/SKzsI0SYgZb71i49k+pNA2CVXzEJAY7agZbjWJ
|
36
|
+
UbgGKN8u9SGbIoQPBPIl97JPIGlR7AoEdmlWyFySaZD4o6+Q0onUXIV+P/KrYTVb
|
37
|
+
Zj/NEjHGrvskpDzlYI2LvG71DFp1o0hfIZzdvfWLAMVqtuEjJ6QrUm9FttR06rNo
|
38
|
+
itgEKl/tNI4M9oKJT0faQ5PvJ70ualcLnwkBLyJVd2r8qwxfjUAjKF8iMpBSb98s
|
39
|
+
YJY7T/W2n+eWy8WuPhzVUkyzguj0bQe27NDeabgCh2mHd4Hynk2AkYh8MQ==
|
39
40
|
-----END CERTIFICATE-----
|
40
41
|
|
41
|
-
date:
|
42
|
+
date: 2012-02-04 00:00:00 Z
|
42
43
|
dependencies:
|
43
44
|
- !ruby/object:Gem::Dependency
|
44
45
|
name: net-http-digest_auth
|
@@ -71,19 +72,19 @@ dependencies:
|
|
71
72
|
requirements:
|
72
73
|
- - ~>
|
73
74
|
- !ruby/object:Gem::Version
|
74
|
-
hash:
|
75
|
+
hash: 11
|
75
76
|
segments:
|
76
77
|
- 2
|
77
|
-
-
|
78
|
-
version: "2.
|
78
|
+
- 4
|
79
|
+
version: "2.4"
|
79
80
|
- - ">="
|
80
81
|
- !ruby/object:Gem::Version
|
81
|
-
hash:
|
82
|
+
hash: 29
|
82
83
|
segments:
|
83
84
|
- 2
|
84
|
-
-
|
85
|
-
-
|
86
|
-
version: 2.
|
85
|
+
- 4
|
86
|
+
- 1
|
87
|
+
version: 2.4.1
|
87
88
|
type: :runtime
|
88
89
|
version_requirements: *id002
|
89
90
|
- !ruby/object:Gem::Dependency
|
@@ -178,28 +179,43 @@ dependencies:
|
|
178
179
|
requirements:
|
179
180
|
- - ~>
|
180
181
|
- !ruby/object:Gem::Version
|
181
|
-
hash:
|
182
|
+
hash: 23
|
182
183
|
segments:
|
183
184
|
- 2
|
184
|
-
-
|
185
|
-
version: "2.
|
185
|
+
- 10
|
186
|
+
version: "2.10"
|
186
187
|
type: :development
|
187
188
|
version_requirements: *id007
|
188
189
|
- !ruby/object:Gem::Dependency
|
189
|
-
name:
|
190
|
+
name: rdoc
|
190
191
|
prerelease: false
|
191
192
|
requirement: &id008 !ruby/object:Gem::Requirement
|
192
193
|
none: false
|
193
194
|
requirements:
|
194
195
|
- - ~>
|
195
196
|
- !ruby/object:Gem::Version
|
196
|
-
hash:
|
197
|
+
hash: 19
|
197
198
|
segments:
|
198
|
-
-
|
199
|
-
-
|
200
|
-
version: "
|
199
|
+
- 3
|
200
|
+
- 10
|
201
|
+
version: "3.10"
|
201
202
|
type: :development
|
202
203
|
version_requirements: *id008
|
204
|
+
- !ruby/object:Gem::Dependency
|
205
|
+
name: hoe
|
206
|
+
prerelease: false
|
207
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
208
|
+
none: false
|
209
|
+
requirements:
|
210
|
+
- - ~>
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
hash: 25
|
213
|
+
segments:
|
214
|
+
- 2
|
215
|
+
- 13
|
216
|
+
version: "2.13"
|
217
|
+
type: :development
|
218
|
+
version_requirements: *id009
|
203
219
|
description: |-
|
204
220
|
The Mechanize library is used for automating interaction with websites.
|
205
221
|
Mechanize automatically stores and sends cookies, follows redirects,
|
@@ -219,7 +235,6 @@ extra_rdoc_files:
|
|
219
235
|
- Manifest.txt
|
220
236
|
- CHANGELOG.rdoc
|
221
237
|
- EXAMPLES.rdoc
|
222
|
-
- FAQ.rdoc
|
223
238
|
- GUIDE.rdoc
|
224
239
|
- LICENSE.rdoc
|
225
240
|
- README.rdoc
|
@@ -227,7 +242,6 @@ files:
|
|
227
242
|
- .autotest
|
228
243
|
- CHANGELOG.rdoc
|
229
244
|
- EXAMPLES.rdoc
|
230
|
-
- FAQ.rdoc
|
231
245
|
- GUIDE.rdoc
|
232
246
|
- LICENSE.rdoc
|
233
247
|
- Manifest.txt
|
@@ -238,6 +252,7 @@ files:
|
|
238
252
|
- examples/proxy_req.rb
|
239
253
|
- examples/rubyforge.rb
|
240
254
|
- examples/spider.rb
|
255
|
+
- examples/wikipedia_links_to_philosophy.rb
|
241
256
|
- lib/mechanize.rb
|
242
257
|
- lib/mechanize/content_type_error.rb
|
243
258
|
- lib/mechanize/cookie.rb
|
@@ -383,6 +398,7 @@ files:
|
|
383
398
|
- test/test_mechanize_subclass.rb
|
384
399
|
- test/test_mechanize_util.rb
|
385
400
|
- test/test_multi_select.rb
|
401
|
+
- test/test_mechanize_response_read_error.rb
|
386
402
|
- .gemtest
|
387
403
|
homepage: http://mechanize.rubyforge.org
|
388
404
|
licenses: []
|
@@ -458,6 +474,7 @@ test_files:
|
|
458
474
|
- test/test_mechanize_pluggable_parser.rb
|
459
475
|
- test/test_mechanize_redirect_limit_reached_error.rb
|
460
476
|
- test/test_mechanize_redirect_not_get_or_head_error.rb
|
477
|
+
- test/test_mechanize_response_read_error.rb
|
461
478
|
- test/test_mechanize_subclass.rb
|
462
479
|
- test/test_mechanize_util.rb
|
463
480
|
- test/test_multi_select.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/FAQ.rdoc
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
Q:: Why do I keep getting an EOFError?
|
2
|
-
|
3
|
-
A:: For older versions of mechanize turning off keep_alive could help with the
|
4
|
-
problem, but mechanize now has more robust handling of persistent
|
5
|
-
connections.
|
6
|
-
|
7
|
-
Older versions of mechanize would raise an EOFError when a chunked body was
|
8
|
-
not terminated properly, a common bug of IIS servers. Since 2.0
|
9
|
-
Mechanize::ResponseReadError is raised containing the original response and
|
10
|
-
body read so far so if the server is broken you can still retrieve the
|
11
|
-
entire content.
|