patron 0.4.13 → 0.4.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,7 +42,7 @@ module Patron
42
42
  @max_redirects = -1
43
43
  end
44
44
 
45
- attr_accessor :url, :username, :password, :file_name, :proxy, :proxy_type, :auth_type, :insecure, :ignore_content_size, :multipart
45
+ attr_accessor :url, :username, :password, :file_name, :proxy, :proxy_type, :auth_type, :insecure, :ignore_content_length, :multipart
46
46
  attr_reader :action, :timeout, :connect_timeout, :max_redirects, :headers, :buffer_size
47
47
  attr_reader :auth_type
48
48
 
@@ -69,7 +69,7 @@ module Patron
69
69
  attr_accessor :insecure
70
70
 
71
71
  # Does this session ignore Content-Size headers?
72
- attr_accessor :ignore_content_size
72
+ attr_accessor :ignore_content_length
73
73
 
74
74
  # Set the buffer size for this request. This option will
75
75
  # only be set if buffer_size is non-nil
@@ -199,7 +199,7 @@ module Patron
199
199
  req.proxy_type = proxy_type
200
200
  req.auth_type = auth_type
201
201
  req.insecure = insecure
202
- req.ignore_content_size = ignore_content_size
202
+ req.ignore_content_length = ignore_content_length
203
203
  req.buffer_size = buffer_size
204
204
 
205
205
  url = self.base_url.to_s + url.to_s
@@ -1,3 +1,3 @@
1
1
  module Patron
2
- VERSION = "0.4.13"
2
+ VERSION = "0.4.14"
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = "Patron HTTP Client"
12
12
  s.description = "Ruby HTTP client library based on libcurl"
13
13
 
14
- s.required_rubygems_version = ">= 1.3.6"
14
+ s.required_rubygems_version = ">= 1.2.0"
15
15
  s.rubyforge_project = "patron"
16
16
 
17
17
  s.add_development_dependency "bundler", ">= 1.0.0"
@@ -94,12 +94,21 @@ class RepetitiveHeaderServlet < HTTPServlet::AbstractServlet
94
94
  end
95
95
  end
96
96
 
97
+ class WrongContentLengthServlet < HTTPServlet::AbstractServlet
98
+ def do_GET(req, res)
99
+ res.keep_alive = false
100
+ res.content_length = 1024
101
+ res.body = "Hello."
102
+ end
103
+ end
104
+
97
105
  server = WEBrick::HTTPServer.new :Port => 9001
98
106
  server.mount("/test", TestServlet)
99
107
  server.mount("/timeout", TimeoutServlet)
100
108
  server.mount("/redirect", RedirectServlet)
101
109
  server.mount("/setcookie", SetCookieServlet)
102
110
  server.mount("/repetitiveheader", RepetitiveHeaderServlet)
111
+ server.mount("/wrongcontentlength", WrongContentLengthServlet)
103
112
 
104
113
  exit_code = lambda do
105
114
  begin
@@ -210,6 +210,20 @@ describe Patron::Session do
210
210
  YAML::load(response).header.should_not include('cookie')
211
211
  end
212
212
 
213
+ it "should ignore a wrong Content-Length when asked to" do
214
+ lambda {
215
+ @session.ignore_content_length = true
216
+ @session.get("/wrongcontentlength")
217
+ }.should_not raise_error
218
+ end
219
+
220
+ it "should fail by default with a Content-Length too high" do
221
+ lambda {
222
+ @session.ignore_content_length = nil
223
+ @session.get("/wrongcontentlength")
224
+ }.should raise_error(Patron::PartialFileError)
225
+ end
226
+
213
227
  it "should raise exception if cookie store is not writable or readable" do
214
228
  lambda { @session.handle_cookies("/trash/clash/foo") }.should raise_error(ArgumentError)
215
229
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: patron
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.13
5
+ version: 0.4.14
6
6
  platform: ruby
7
7
  authors:
8
8
  - Phillip Toland
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-21 00:00:00 -05:00
13
+ date: 2011-07-28 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 1.3.6
120
+ version: 1.2.0
121
121
  requirements: []
122
122
 
123
123
  rubyforge_project: patron