mechanize 2.5 → 2.5.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 CHANGED
Binary file
@@ -1,8 +1,14 @@
1
1
  = Mechanize CHANGELOG
2
2
 
3
+ === 2.5.1
4
+
5
+ * Bug fix
6
+ * Mechanize no longer copies POST requests during a redirect which was
7
+ introduced by #215. Pull request #229 by Godfrey Chan.
8
+
3
9
  === 2.5
4
10
 
5
- * Minor enhancement
11
+ * Minor enhancements
6
12
  * Added Mechanize#ignore_bad_chunking for working around servers that don't
7
13
  terminate chunked transfer-encoding properly. Enabling this may cause
8
14
  data loss. Issue #116
@@ -5,11 +5,13 @@ require 'mechanize'
5
5
  require 'logger'
6
6
 
7
7
  # Create a new mechanize object
8
- agent = Mechanize.new { |a| a.log = Logger.new(STDERR) }
8
+ mech = Mechanize.new
9
+ mech.log = Logger.new $stderr
10
+ mech.agent.http.debug_output = $stderr
9
11
 
10
12
  # Load the rubyforge website
11
- page = agent.get('http://rubyforge.org/')
12
- page = agent.click page.link_with(:text => /Log In/) # Click the login link
13
+ page = mech.get('http://rubyforge.org/')
14
+ page = mech.click page.link_with(:text => /Log In/) # Click the login link
13
15
  form = page.forms[1] # Select the first form
14
16
  form.form_loginname = ARGV[0]
15
17
  form.form_pw = ARGV[1]
@@ -73,7 +73,7 @@ class Mechanize
73
73
  ##
74
74
  # The version of Mechanize you are using.
75
75
 
76
- VERSION = '2.5'
76
+ VERSION = '2.5.1'
77
77
 
78
78
  ##
79
79
  # Base mechanize error class
@@ -938,6 +938,11 @@ class Mechanize::HTTP::Agent
938
938
 
939
939
  redirect_method = method == :head ? :head : :get
940
940
 
941
+ # Make sure we are not copying over the POST headers from the original request
942
+ ['Content-Length', 'Content-MD5', 'Content-Type'].each do |key|
943
+ headers.delete key
944
+ end
945
+
941
946
  @history.push(page, page.uri)
942
947
  new_uri = resolve response['Location'].to_s, page
943
948
 
@@ -1384,6 +1384,8 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1384
1384
 
1385
1385
  headers = {
1386
1386
  'Range' => 'bytes=0-9999',
1387
+ 'Content-Type' => 'application/x-www-form-urlencoded',
1388
+ 'Content-Length' => '9999',
1387
1389
  }
1388
1390
 
1389
1391
  page = fake_page
@@ -1392,7 +1394,9 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1392
1394
 
1393
1395
  assert_equal URI('http://fake.example/http_headers'), page.uri
1394
1396
 
1395
- assert_match 'range|bytes=0-999', page.body
1397
+ assert_match 'range|bytes=0-9999', page.body
1398
+ refute_match 'content-type|application/x-www-form-urlencoded', page.body
1399
+ refute_match 'content-length|9999', page.body
1396
1400
  end
1397
1401
 
1398
1402
  def test_response_redirect_malformed
@@ -1414,7 +1418,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1414
1418
 
1415
1419
  assert_raises Mechanize::RedirectLimitReachedError do
1416
1420
  @agent.response_redirect({ 'Location' => '/index.html' }, :get,
1417
- fake_page, @agent.redirection_limit, referer)
1421
+ fake_page, @agent.redirection_limit, {}, referer)
1418
1422
  end
1419
1423
  end
1420
1424
 
@@ -1423,7 +1427,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1423
1427
 
1424
1428
  page = fake_page
1425
1429
  page = @agent.response_redirect({ 'Location' => '/other' }, :get, page, 0,
1426
- page)
1430
+ {}, page)
1427
1431
 
1428
1432
  assert_equal URI('http://fake.example'), page.uri
1429
1433
  end
@@ -1435,7 +1439,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1435
1439
  response.instance_variable_set :@header, { 'location' => %w[/index.html] }
1436
1440
 
1437
1441
  page = fake_page
1438
- page = @agent.response_redirect response, :get, page, 0, page
1442
+ page = @agent.response_redirect response, :get, page, 0, {}, page
1439
1443
 
1440
1444
  assert_equal URI('http://fake.example/index.html'), page.uri
1441
1445
  end
@@ -1447,7 +1451,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1447
1451
  response.instance_variable_set :@header, { 'location' => %w[/index.html] }
1448
1452
 
1449
1453
  page = fake_page
1450
- page = @agent.response_redirect response, :get, page, 0, page
1454
+ page = @agent.response_redirect response, :get, page, 0, {}, page
1451
1455
 
1452
1456
  assert_equal URI('http://fake.example/'), page.uri
1453
1457
  end
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: 9
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 5
9
- version: "2.5"
9
+ - 1
10
+ version: 2.5.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Eric Hodel
@@ -39,7 +40,7 @@ cert_chain:
39
40
  U81zGHMUBOvz/VGT6wJwYJ3emS2nfA2NOHFfgA==
40
41
  -----END CERTIFICATE-----
41
42
 
42
- date: 2012-05-09 00:00:00 Z
43
+ date: 2012-05-15 00:00:00 Z
43
44
  dependencies:
44
45
  - !ruby/object:Gem::Dependency
45
46
  name: net-http-digest_auth
metadata.gz.sig CHANGED
Binary file