mechanize 0.6.6 → 0.6.7

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.

@@ -1,5 +1,10 @@
1
1
  = Mechanize CHANGELOG
2
2
 
3
+ == 0.6.7
4
+
5
+ * Fixed a bug with keep-alive requests
6
+ * [#9549] fixed problem with cookie paths
7
+
3
8
  == 0.6.6
4
9
 
5
10
  * Removing hpricot overrides
@@ -62,7 +62,7 @@ class Mechanize
62
62
  ##
63
63
  # The version of Mechanize you are using.
64
64
 
65
- VERSION = '0.6.6'
65
+ VERSION = '0.6.7'
66
66
 
67
67
  ##
68
68
  # User Agent aliases
@@ -391,6 +391,8 @@ class Mechanize
391
391
  end
392
392
  end
393
393
 
394
+ http_obj.start unless http_obj.started?
395
+
394
396
  request = set_headers(uri, request, cur_page)
395
397
 
396
398
  # Log specified headers for the request
@@ -405,7 +407,7 @@ class Mechanize
405
407
  http_obj.read_timeout = @read_timeout if @read_timeout
406
408
 
407
409
  # Send the request
408
- http_obj.request(request, *request_data) {|response|
410
+ response = http_obj.request(request, *request_data) {|response|
409
411
  if log
410
412
  response.each_header {|k,v|
411
413
  log.debug("response-header: #{ k } => #{ v }")
@@ -460,27 +462,28 @@ class Mechanize
460
462
  end
461
463
  }
462
464
 
463
- log.info("status: #{ page.code }") if log
465
+ }
464
466
 
465
- res_klass = Net::HTTPResponse::CODE_TO_OBJ[page.code.to_s]
467
+ log.info("status: #{ page.code }") if log
466
468
 
467
- return page if res_klass <= Net::HTTPSuccess
469
+ res_klass = Net::HTTPResponse::CODE_TO_OBJ[page.code.to_s]
468
470
 
469
- if res_klass == Net::HTTPNotModified
470
- log.debug("Got cached page") if log
471
- return visited_page(uri)
472
- elsif res_klass <= Net::HTTPRedirection
473
- return page unless follow_redirect?
474
- log.info("follow redirect to: #{ response['Location'] }") if log
475
- from_uri = page.uri
476
- abs_uri = to_absolute_uri(response['Location'].to_s, page)
477
- page = fetch_page(abs_uri, fetch_request(abs_uri), page)
478
- @history.push(page, from_uri)
479
- return page
480
- end
471
+ return page if res_klass <= Net::HTTPSuccess
481
472
 
482
- raise ResponseCodeError.new(page), "Unhandled response", caller
483
- }
473
+ if res_klass == Net::HTTPNotModified
474
+ log.debug("Got cached page") if log
475
+ return visited_page(uri)
476
+ elsif res_klass <= Net::HTTPRedirection
477
+ return page unless follow_redirect?
478
+ log.info("follow redirect to: #{ response['Location'] }") if log
479
+ from_uri = page.uri
480
+ abs_uri = to_absolute_uri(response['Location'].to_s, page)
481
+ page = fetch_page(abs_uri, fetch_request(abs_uri), page)
482
+ @history.push(page, from_uri)
483
+ return page
484
+ end
485
+
486
+ raise ResponseCodeError.new(page), "Unhandled response", caller
484
487
  end
485
488
 
486
489
  def self.build_query_string(parameters)
@@ -48,7 +48,8 @@ module WWW
48
48
  when "secure" then cookie.secure = true
49
49
  end
50
50
  }
51
- cookie.path ||= uri.path
51
+
52
+ cookie.path ||= uri.path.to_s.sub(/[^\/]*$/, '')
52
53
  cookie.secure ||= false
53
54
  cookie.domain ||= uri.host
54
55
  # Move this in to the cookie jar
@@ -171,7 +171,7 @@ class CookieClassTest < Test::Unit::TestCase
171
171
 
172
172
  # If no path was given, use the one from the URL
173
173
  def test_cookie_using_url_path
174
- url = URI.parse('http://rubyforge.org/login')
174
+ url = URI.parse('http://rubyforge.org/login.php')
175
175
  cookie_params = {}
176
176
  cookie_params['expires'] = 'expires=Sun, 27-Sep-2037 00:00:00 GMT'
177
177
  cookie_params['path'] = 'path=/'
@@ -196,7 +196,7 @@ class CookieClassTest < Test::Unit::TestCase
196
196
  assert_not_nil(cookie)
197
197
  assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)
198
198
  assert_equal('rubyforge.org', cookie.domain)
199
- assert_equal('/login', cookie.path)
199
+ assert_equal('/', cookie.path)
200
200
 
201
201
  # if expires was set, make sure we parsed it
202
202
  if c.find { |k| k == 'expires' }
@@ -15,7 +15,7 @@ class CookiesMechTest < Test::Unit::TestCase
15
15
  def test_send_cookies
16
16
  page = @agent.get("http://localhost:#{PORT}/many_cookies")
17
17
  page = @agent.get("http://localhost:#{PORT}/send_cookies")
18
- assert_equal(2, page.links.length)
18
+ assert_equal(3, page.links.length)
19
19
  assert_not_nil(page.links.find { |l| l.text == "name:Aaron" })
20
20
  assert_not_nil(page.links.find { |l| l.text == "no_expires:nope" })
21
21
  end
@@ -57,7 +57,7 @@ class CookiesMechTest < Test::Unit::TestCase
57
57
  no_path_cookie = @agent.cookies.find { |k| k.name == "no_path" }
58
58
  assert_not_nil(no_path_cookie, "No path cookie is nil")
59
59
  assert_equal("no_path", no_path_cookie.value)
60
- assert_equal("/many_cookies_as_string", no_path_cookie.path)
60
+ assert_equal("/", no_path_cookie.path)
61
61
  assert_equal(true, Time.now < no_path_cookie.expires)
62
62
  end
63
63
 
@@ -88,7 +88,7 @@ class CookiesMechTest < Test::Unit::TestCase
88
88
  no_path_cookie = @agent.cookies.find { |k| k.name == "no_path" }
89
89
  assert_not_nil(no_path_cookie, "No path cookie is nil")
90
90
  assert_equal("no_path", no_path_cookie.value)
91
- assert_equal("/many_cookies", no_path_cookie.path)
91
+ assert_equal("/", no_path_cookie.path)
92
92
  assert_equal(true, Time.now < no_path_cookie.expires)
93
93
  end
94
94
 
@@ -72,7 +72,8 @@ class Net::HTTP
72
72
  res.cookies.each do |cookie|
73
73
  res.add_field('Set-Cookie', cookie.to_s)
74
74
  end
75
- yield res
75
+ yield res if block_given?
76
+ res
76
77
  end
77
78
  end
78
79
 
metadata CHANGED
@@ -1,178 +1,177 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: mechanize
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.6.6
7
- date: 2007-03-24 00:00:00 -07:00
6
+ version: 0.6.7
7
+ date: 2007-03-27 00:00:00 -07:00
8
8
  summary: Mechanize provides automated web-browsing
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: aaronp@rubyforge.org
12
12
  homepage: http://mechanize.rubyforge.org/
13
13
  rubyforge_project: mechanize
14
- description: "The Mechanize library is used for automating interaction with websites.
15
- Mechanize automatically stores and sends cookies, follows redirects, can follow
16
- links, and submit forms. Form fields can be populated and submitted. Mechanize
17
- also keeps track of the sites that you have visited as a history."
14
+ description: The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.
18
15
  autorequire:
19
16
  default_executable:
20
17
  bindir: bin
21
18
  has_rdoc: true
22
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
23
20
  requirements:
24
- -
25
- - ">"
26
- - !ruby/object:Gem::Version
27
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
28
24
  version:
29
25
  platform: ruby
30
26
  signing_key:
31
27
  cert_chain:
32
28
  post_install_message:
33
29
  authors:
34
- - Aaron Patterson
30
+ - Aaron Patterson
35
31
  files:
36
- - CHANGELOG.txt
37
- - EXAMPLES.txt
38
- - GUIDE.txt
39
- - LICENSE.txt
40
- - Manifest.txt
41
- - NOTES.txt
42
- - README.txt
43
- - Rakefile
44
- - eg/flickr_upload.rb
45
- - eg/mech-dump.rb
46
- - eg/proxy_req.rb
47
- - eg/rubyforge.rb
48
- - eg/spider.rb
49
- - lib/mechanize.rb
50
- - lib/mechanize/cookie.rb
51
- - lib/mechanize/errors.rb
52
- - lib/mechanize/form.rb
53
- - lib/mechanize/form_elements.rb
54
- - lib/mechanize/history.rb
55
- - lib/mechanize/inspect.rb
56
- - lib/mechanize/list.rb
57
- - lib/mechanize/net-overrides/net/http.rb
58
- - lib/mechanize/net-overrides/net/https.rb
59
- - lib/mechanize/net-overrides/net/protocol.rb
60
- - lib/mechanize/page.rb
61
- - lib/mechanize/page_elements.rb
62
- - lib/mechanize/parsers/rexml_page.rb
63
- - lib/mechanize/pluggable_parsers.rb
64
- - lib/mechanize/rexml.rb
65
- - setup.rb
66
- - test/data/htpasswd
67
- - test/data/server.crt
68
- - test/data/server.csr
69
- - test/data/server.key
70
- - test/data/server.pem
71
- - test/htdocs/alt_text.html
72
- - test/htdocs/bad_form_test.html
73
- - test/htdocs/button.jpg
74
- - test/htdocs/empty_form.html
75
- - test/htdocs/file_upload.html
76
- - test/htdocs/find_link.html
77
- - test/htdocs/form_multi_select.html
78
- - test/htdocs/form_multival.html
79
- - test/htdocs/form_no_action.html
80
- - test/htdocs/form_no_input_name.html
81
- - test/htdocs/form_select.html
82
- - test/htdocs/form_select_all.html
83
- - test/htdocs/form_select_none.html
84
- - test/htdocs/form_select_noopts.html
85
- - test/htdocs/form_set_fields.html
86
- - test/htdocs/form_test.html
87
- - test/htdocs/frame_test.html
88
- - test/htdocs/google.html
89
- - test/htdocs/iframe_test.html
90
- - test/htdocs/index.html
91
- - test/htdocs/link with space.html
92
- - test/htdocs/no_title_test.html
93
- - test/htdocs/relative/tc_relative_links.html
94
- - test/htdocs/tc_bad_links.html
95
- - test/htdocs/tc_checkboxes.html
96
- - test/htdocs/tc_encoded_links.html
97
- - test/htdocs/tc_form_action.html
98
- - test/htdocs/tc_links.html
99
- - test/htdocs/tc_no_attributes.html
100
- - test/htdocs/tc_pretty_print.html
101
- - test/htdocs/tc_radiobuttons.html
102
- - test/htdocs/tc_referer.html
103
- - test/htdocs/tc_relative_links.html
104
- - test/htdocs/tc_textarea.html
105
- - test/ssl_server.rb
106
- - test/tc_authenticate.rb
107
- - test/tc_bad_links.rb
108
- - test/tc_checkboxes.rb
109
- - test/tc_cookie_class.rb
110
- - test/tc_cookie_jar.rb
111
- - test/tc_cookies.rb
112
- - test/tc_encoded_links.rb
113
- - test/tc_errors.rb
114
- - test/tc_form_action.rb
115
- - test/tc_form_as_hash.rb
116
- - test/tc_form_button.rb
117
- - test/tc_form_no_inputname.rb
118
- - test/tc_forms.rb
119
- - test/tc_frames.rb
120
- - test/tc_gzipping.rb
121
- - test/tc_history.rb
122
- - test/tc_html_unscape_forms.rb
123
- - test/tc_if_modified_since.rb
124
- - test/tc_links.rb
125
- - test/tc_mech.rb
126
- - test/tc_multi_select.rb
127
- - test/tc_no_attributes.rb
128
- - test/tc_page.rb
129
- - test/tc_pluggable_parser.rb
130
- - test/tc_post_form.rb
131
- - test/tc_pretty_print.rb
132
- - test/tc_proxy.rb
133
- - test/tc_radiobutton.rb
134
- - test/tc_referer.rb
135
- - test/tc_relative_links.rb
136
- - test/tc_response_code.rb
137
- - test/tc_save_file.rb
138
- - test/tc_select.rb
139
- - test/tc_select_all.rb
140
- - test/tc_select_none.rb
141
- - test/tc_select_noopts.rb
142
- - test/tc_set_fields.rb
143
- - test/tc_ssl_server.rb
144
- - test/tc_subclass.rb
145
- - test/tc_textarea.rb
146
- - test/tc_upload.rb
147
- - test/tc_watches.rb
148
- - test/test_all.rb
149
- - test/test_includes.rb
150
- - test/test_servlets.rb
32
+ - CHANGELOG.txt
33
+ - EXAMPLES.txt
34
+ - GUIDE.txt
35
+ - LICENSE.txt
36
+ - Manifest.txt
37
+ - NOTES.txt
38
+ - README.txt
39
+ - Rakefile
40
+ - eg/flickr_upload.rb
41
+ - eg/mech-dump.rb
42
+ - eg/proxy_req.rb
43
+ - eg/rubyforge.rb
44
+ - eg/spider.rb
45
+ - lib/mechanize.rb
46
+ - lib/mechanize/cookie.rb
47
+ - lib/mechanize/errors.rb
48
+ - lib/mechanize/form.rb
49
+ - lib/mechanize/form_elements.rb
50
+ - lib/mechanize/history.rb
51
+ - lib/mechanize/inspect.rb
52
+ - lib/mechanize/list.rb
53
+ - lib/mechanize/net-overrides/net/http.rb
54
+ - lib/mechanize/net-overrides/net/https.rb
55
+ - lib/mechanize/net-overrides/net/protocol.rb
56
+ - lib/mechanize/page.rb
57
+ - lib/mechanize/page_elements.rb
58
+ - lib/mechanize/parsers/rexml_page.rb
59
+ - lib/mechanize/pluggable_parsers.rb
60
+ - lib/mechanize/rexml.rb
61
+ - setup.rb
62
+ - test/data/htpasswd
63
+ - test/data/server.crt
64
+ - test/data/server.csr
65
+ - test/data/server.key
66
+ - test/data/server.pem
67
+ - test/htdocs/alt_text.html
68
+ - test/htdocs/bad_form_test.html
69
+ - test/htdocs/button.jpg
70
+ - test/htdocs/empty_form.html
71
+ - test/htdocs/file_upload.html
72
+ - test/htdocs/find_link.html
73
+ - test/htdocs/form_multi_select.html
74
+ - test/htdocs/form_multival.html
75
+ - test/htdocs/form_no_action.html
76
+ - test/htdocs/form_no_input_name.html
77
+ - test/htdocs/form_select.html
78
+ - test/htdocs/form_select_all.html
79
+ - test/htdocs/form_select_none.html
80
+ - test/htdocs/form_select_noopts.html
81
+ - test/htdocs/form_set_fields.html
82
+ - test/htdocs/form_test.html
83
+ - test/htdocs/frame_test.html
84
+ - test/htdocs/google.html
85
+ - test/htdocs/iframe_test.html
86
+ - test/htdocs/index.html
87
+ - test/htdocs/link with space.html
88
+ - test/htdocs/no_title_test.html
89
+ - test/htdocs/relative/tc_relative_links.html
90
+ - test/htdocs/tc_bad_links.html
91
+ - test/htdocs/tc_checkboxes.html
92
+ - test/htdocs/tc_encoded_links.html
93
+ - test/htdocs/tc_form_action.html
94
+ - test/htdocs/tc_links.html
95
+ - test/htdocs/tc_no_attributes.html
96
+ - test/htdocs/tc_pretty_print.html
97
+ - test/htdocs/tc_radiobuttons.html
98
+ - test/htdocs/tc_referer.html
99
+ - test/htdocs/tc_relative_links.html
100
+ - test/htdocs/tc_textarea.html
101
+ - test/ssl_server.rb
102
+ - test/tc_authenticate.rb
103
+ - test/tc_bad_links.rb
104
+ - test/tc_checkboxes.rb
105
+ - test/tc_cookie_class.rb
106
+ - test/tc_cookie_jar.rb
107
+ - test/tc_cookies.rb
108
+ - test/tc_encoded_links.rb
109
+ - test/tc_errors.rb
110
+ - test/tc_form_action.rb
111
+ - test/tc_form_as_hash.rb
112
+ - test/tc_form_button.rb
113
+ - test/tc_form_no_inputname.rb
114
+ - test/tc_forms.rb
115
+ - test/tc_frames.rb
116
+ - test/tc_gzipping.rb
117
+ - test/tc_history.rb
118
+ - test/tc_html_unscape_forms.rb
119
+ - test/tc_if_modified_since.rb
120
+ - test/tc_links.rb
121
+ - test/tc_mech.rb
122
+ - test/tc_multi_select.rb
123
+ - test/tc_no_attributes.rb
124
+ - test/tc_page.rb
125
+ - test/tc_pluggable_parser.rb
126
+ - test/tc_post_form.rb
127
+ - test/tc_pretty_print.rb
128
+ - test/tc_proxy.rb
129
+ - test/tc_radiobutton.rb
130
+ - test/tc_referer.rb
131
+ - test/tc_relative_links.rb
132
+ - test/tc_response_code.rb
133
+ - test/tc_save_file.rb
134
+ - test/tc_select.rb
135
+ - test/tc_select_all.rb
136
+ - test/tc_select_none.rb
137
+ - test/tc_select_noopts.rb
138
+ - test/tc_set_fields.rb
139
+ - test/tc_ssl_server.rb
140
+ - test/tc_subclass.rb
141
+ - test/tc_textarea.rb
142
+ - test/tc_upload.rb
143
+ - test/tc_watches.rb
144
+ - test/test_all.rb
145
+ - test/test_includes.rb
146
+ - test/test_servlets.rb
151
147
  test_files:
152
- - test/test_all.rb
148
+ - test/test_all.rb
153
149
  rdoc_options: []
150
+
154
151
  extra_rdoc_files: []
152
+
155
153
  executables: []
154
+
156
155
  extensions: []
156
+
157
157
  requirements: []
158
+
158
159
  dependencies:
159
- - !ruby/object:Gem::Dependency
160
- name: hpricot
161
- version_requirement:
162
- version_requirements: !ruby/object:Gem::Version::Requirement
163
- requirements:
164
- -
165
- - ">"
166
- - !ruby/object:Gem::Version
167
- version: 0.0.0
168
- version:
169
- - !ruby/object:Gem::Dependency
170
- name: hoe
171
- version_requirement:
172
- version_requirements: !ruby/object:Gem::Version::Requirement
173
- requirements:
174
- -
175
- - ">="
176
- - !ruby/object:Gem::Version
177
- version: 1.2.0
178
- version:
160
+ - !ruby/object:Gem::Dependency
161
+ name: hpricot
162
+ version_requirement:
163
+ version_requirements: !ruby/object:Gem::Version::Requirement
164
+ requirements:
165
+ - - ">"
166
+ - !ruby/object:Gem::Version
167
+ version: 0.0.0
168
+ version:
169
+ - !ruby/object:Gem::Dependency
170
+ name: hoe
171
+ version_requirement:
172
+ version_requirements: !ruby/object:Gem::Version::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: 1.2.0
177
+ version: